- ERROR Dispatcher Could not find action or result: /itcast_OA/role_add.do
Wrong method was defined as an action method: add - [unknown location]
解决办法: 如下代码中,add方法是不能含有参数的,将参数去掉即可
public String add(Role model){
roleService.save(model);
return "toList";
}
- 找不到mapping和action问题
struts2.5 版本,检查了好多遍,总是报没有找到对应的mapping和action,最后网上看到,struts2.5 默认设置了global-allowed-methods,只有里面的方法才能通过,因而必须在自己的action下allowed-methods标签中添加上自己的方法名称才行。
<global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index</global-allowed-methods>
解决办法: 如下所示,添加allowed-methods 即可,其中editui是自己action类中的方法名称。
<action name="role_*" class="roleAction" method="{1}">
<result name="list">/WEB-INF/jsp/role/list.jsp</result>
<result name="toList" type="redirectAction">
<param name="actionName">role_list</param>
<param name="namespace">/</param>
</result>
<result name="editUI">/WEB-INF/jsp/role/edit.jsp</result>
<allowed-methods>editui</allowed-methods>
</action>
网友评论