当我发送这个帖子请求时,我收到了这个错误:
org.springframework.web.HttpSessionRequiredException: Expected session attribute
'form'
at org.springframework.web.method.annotation.ModelFactory.initModel
这种异常的原因(可能性)是什么?我正在使用 Spring MVC 开发此 Web 应用程序。
@RequestMapping(value = "/new/form",params ="mode",method = RequestMethod.POST)
public String newForm(@ModelAttribute("form") ApplicationForm form,
BindingResult bindingResult,
@RequestParam String mode,
Model model,
SessionStatus sessionStatus) {
return showSearchForm(model);
}
最佳答案
尝试在类(class)开始时使用这些注释
@SessionAttributes({"form"})
@Controller
关于java - 错误 : Expected session attribute 'form' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17654464/