我的應用程序有一個帶強制複選框的註冊頁面。如果提交表單時沒有勾選複選框,我希望在嘗試提交表單時顯示錯誤消息。rejectValue並在jsp中使用。 spring3 mvc; JSP;
在我的控制,我有:
if(req.getParameter("tcCheck")==null)
result.rejectValue("tcCheck","Check.tc", "Need to accept terms and conditions");
我的jsp:
<form:form modelAttribute="user" method="post">
...
<form:errors path=tcCheck/>
...
</form:form>
在運行時,我得到這個錯誤:
Error 500: org.springframework.beans.NotReadablePropertyException: Invalid property 'tcCheck' of bean class [com.domgen.recupl.domain.User]: Bean property 'tcCheck' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
用戶域對象沒有tcCheck作爲它的一個實例變量,當然它不應該放在User bean中。
我想知道如何在不編輯用戶bean的情況下顯示錯誤信息? 謝謝。
A
這是我想已經這樣做並沒有奏效。 –