struts2中进行有效性校验时练习的小例子中产生下面的报错信息:
页面显示:HTTP Status 404 - No result defined for action com.action.personAction and result input
控制台显示:
警告: Could not find action or result
No result defined for action com.action.personAction and result input
No result defined for action com.action.personAction and result input
出错原因是:
1)前台请求页面的属性值和action中对应的属性值写错了个单词,导致action获取不到,属性值为空。
Action中的属性值为空,Struts2的默认拦截器会报错,找不到input的result,不能把错误返回。只能报找不到result.
2)在进行校验时,在配置文件中没有指定input返回视图
系统包含fieldErrors失败信息时,struts2会将请求转发到name为input的result。在input视图中可以显示校验不通过的报错提示信息。通过:<%@taglib uri="/struts-tags" prefix="s"%> <s:fielderror/>
<action name = "validate_*" class = "com.action.personAction" method = "save">
<result name="input">/index.jsp</result> <!--少这行报错 -->
<result name = "success" >/WEB-INF/page/validate.jsp</result>
</action>
<result name="input">/index.jsp</result> <!--少这行报错 -->
<result name = "success" >/WEB-INF/page/validate.jsp</result>
</action>
导致这个报错的原因太多...