Java 带注释的Spring MVC验证表单
我尝试使用执行验证,并添加了注释,如Java 带注释的Spring MVC验证表单,java,spring,tomcat,spring-mvc,Java,Spring,Tomcat,Spring Mvc,我尝试使用执行验证,并添加了注释,如@NotNull、@Size(min=5,max=40)。当我发送正确的值时,一切正常,但当我首先发送错误的值时,Apache Tomcat/7.0.47中出现以下错误: HTTP状态500-处理程序处理失败;嵌套异常为java.lang.ExceptionInInitializeError 类型异常报告 消息处理程序处理失败;嵌套异常为java.lang.ExceptionInInitializeError 说明服务器遇到内部错误,无法满足此请求 异常org
@NotNull、@Size(min=5,max=40)
。当我发送正确的值时,一切正常,但当我首先发送错误的值时,Apache Tomcat/7.0.47中出现以下错误:
HTTP状态500-处理程序处理失败;嵌套异常为java.lang.ExceptionInInitializeError
类型异常报告
消息处理程序处理失败;嵌套异常为java.lang.ExceptionInInitializeError
说明服务器遇到内部错误,无法满足此请求
异常org.springframework.web.util.NestedServletException:处理程序处理失败;嵌套异常为java.lang.ExceptionInInitializeError
javax.el.ELException:找不到类型为org.apache.el.ExpressionFactoryImpl的ExpressionFactory
java.lang.ExceptionInInitializeError
javax.el.ELException:找不到类型为org.apache.el.ExpressionFactoryImpl的ExpressionFactory
当我刷新站点并再次尝试发送错误值时,我会收到另一个错误:
HTTP状态500-处理程序处理失败;嵌套异常为java.lang.NoClassDefFoundError:无法初始化类org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm
类型异常报告
消息处理程序处理失败;嵌套异常为java.lang.NoClassDefFoundError:无法初始化类org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm
说明服务器遇到内部错误,无法满足此请求
异常org.springframework.web.util.NestedServletException:处理程序处理失败;嵌套异常为java.lang.NoClassDefFoundError:无法初始化类org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm
java.lang.NoClassDefFoundError:无法初始化类org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTerm
这是我的控制器中的操作:
@RequestMapping(value = "testform", method=RequestMethod.GET)
public String testForm(Foo foo){
return "test/testform";
}
@RequestMapping(value="testform", method=RequestMethod.POST)
public String checkPersonInfo(@Valid Foo foo, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return "test/testform";
}
return "redirect:/admin/venue/testform";
}
<form action="#" th:action="@{/admin/venue/testform}" th:object="${foo}" method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" th:field="*{name}" /></td>
<!--<td th:if="${#fields.hasErrors('name')}" th:errors="*{name}">Name Error</td>-->
</tr>
<tr>
<td><button type="submit">Submit</button></td>
</tr>
</table>
和视图:
@RequestMapping(value = "testform", method=RequestMethod.GET)
public String testForm(Foo foo){
return "test/testform";
}
@RequestMapping(value="testform", method=RequestMethod.POST)
public String checkPersonInfo(@Valid Foo foo, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return "test/testform";
}
return "redirect:/admin/venue/testform";
}
<form action="#" th:action="@{/admin/venue/testform}" th:object="${foo}" method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" th:field="*{name}" /></td>
<!--<td th:if="${#fields.hasErrors('name')}" th:errors="*{name}">Name Error</td>-->
</tr>
<tr>
<td><button type="submit">Submit</button></td>
</tr>
</table>
姓名:
提交
有没有办法解决这个问题?可能Tomcat缺少一些LIB?可能的副本在哪里可以找到此副本?我没有将el api添加到我的maven依赖项中。我刚刚找到两个文件el-api.jar,第一个在tomcat/lib/el-api.jar上,第二个在intellijidea 13.0/lib/el-api-2.2.jar上。我试着在ide内的tomcat配置中添加el-api.jar,将tomcat库更改为el-api2.2无帮助。不要在问题标题中编辑“已解决”(或类似)。将您的解决方案发布为答案,而不是对问题的编辑。