<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">1.struts-config.xml文件action没有配置正</span>
例如:
正确的配置
<struts-config>
<action-mappings>
<action path="/person" type="action.PersonAction">
<forward name="success" path="/index.jsp" />
</action>
</action-mappings>
</struts-config>
错误的配置
<struts-config>
<action-mappings>
<action path="/person" type="action.PersonAction">
<forward name="success" path="index.jsp" />
</action>
</action-mappings>
</struts-config>
额,谁都有手哆嗦的时候····比如这哥们 http://zghbwjl.blog.163.com/blog/static/120336672201010133847839/
2.重写Action中的execute方法错误
执行的是这个execute方法
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
<span style="color:#ff0000;">HttpServletRequest request, HttpServletResponse response</span>)
throws Exception {
return mapping.findForward("success");
}
而不是这个
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
<span style="color:#ff0000;">ServletRequest request, ServletResponse response</span>) throws Exception {
return mapping.findForward("success");
}
参考:
http://nannan408.iteye.com/blog/696033
http://blog.csdn.net/kaihua_86/article/details/4464365
3.没有找到对应的forward
例如:
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return null;
}
或者
return mapping.findForward("success");
但是在struts-config.xml中没有对应的
<forward name="success" path="/index.jsp" />
In a word,sturts的工作原理是action处理业务,即访问action的时候回去找对应的Action类,然后执行(正确的那个)execute方法,执行完之后返回结果“ActionForward”,在struts-config.xml文件中找到对应的forward,跳转页面。