2
我在提交我的形式收到以下錯誤發現:Spring MVC的: - 會話屬性需要閉會期間
org.springframework.web.HttpSessionRequiredException: Session attribute 'rulesForm' required - not found in session
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.raiseSessionRequiredException(AnnotationMethodHandlerAdapter.java:722)
我的JSP包含以下內容:
<form:form id="rulesForm" modelAttribute="rulesForm" action="save.do">
...
</form>
我的控制器包含以下:
@Controller
@RequestMapping("/rules")
@SessionAttributes({"rulesForm", "deskForm"})
public class RulesController {
.
.
.
@RequestMapping(value = "/save.do")
public ModelAndView saveRuleAttributesAndRules(@Valid
@ModelAttribute("rulesForm")
RulesFormDTO rulesForm, BindingResult bindingResult, HttpSession session, Principal principal) {
看來,如果我讓我的瀏覽器打開一段時間,我的表單顯示g然後我嘗試執行提交一段時間後出現此錯誤。
真的,我想在這種情況下發生的事情是爲了創建新的「rulesForm」對象......我該如何實現這一目標?
感謝
添加@ModelAttribute方法並不是我想要的。我希望將表單中發佈的數據映射到RulesForm對象。如果我的表單被提交,它不會執行綁定? – DJ180