【发布时间】:2020-08-17 17:07:05
【问题描述】:
我似乎找不到解决办法。
我有返回 ModelAndView 来查看网页的方法。
每当条件为真时,我都会存储一个网页文件名来建模。
例子:
@RequestMapping(value = "/process", method = RequestMethod.POST)
public ModelAndView processRequest(HttpServletRequest request,
HttpServletRequest response, Model model,@RequestParam("file") MultipartFile file)
throws IOException {
if (file.isEmpty()) {
model.addAttribute("exception", "web_file1")
} else {
model.addAttribute("exception", "web_file2")
}
如何检索存储在“异常”中的数据并将其设置为 ModelAndView?
ModelAndView mav = new ModelAndView();
mav.setViewName("exception");
//expected:web_file2
//actual:exception
return mav;
【问题讨论】:
标签: java http spring-mvc request-mapping modelandview