No result defined for action xxxAction and result input

xiaoxiao2021-02-27  223

今天使用Struts2框架从前台提交表单到后台,报错如下:

No result defined for action com.google.action.EmpAction and result input - action - file:/D:/develop/apache-tomcat-7.0.76 /webapps/Struts2_hibernate/WEBINF/classes/struts.xml:8:75

后来检查了配置文件路径,没有问题。后来查资料,发现原因如下:

Action的配置文件内少一个name为input的结果视图。这个input结果视图是Struts2定义的当验证参数出错时产生的默认结果。说明前台表单提交的参数与后台action中的属性不匹配。

解决方法:

在action中配置一个name为input的结果视图 <result name="input">/error.jsp</result> 在对应的结构视图error.jsp页面中配置两个标签。 <s:fielderror/>和<s:actionerror/>

这样前台页面上具体的错误信息就会打印到页面上,修改代码,问题完美解决。

转载请注明原文地址: https://www.6miu.com/read-10306.html

最新回复(0)