您的位置:首页 > 移动开发

Struts中 There is no Action mapped for namespace [/] and action name []

2016-10-18 09:29 513 查看
在使用了新版Struts2.5时,之前配置的action出了错,爆出如下异常

HTTP Status 404 - There is no Action mapped for namespace [/person] and action name [personAction_getPersonByID] associated with context path [/ssh].

type Status report

message There is no Action mapped for namespace [/person] and action name [personAction_getPersonByID] associated with context path [/ssh].

description The requested resource is not available.我之前配置是这样的
<struts>
<package name="person" namespace="/person" extends="struts-default">
<action name="personAction_*" method="{1}" class="com.zjt.action.PersonAction">
<result name="index">/index.jsp</result>

</action>
</package>
</struts>
经过查找资料,发现,自从Struts2.3之后,通过*和method{}访问的方法默认是不被允许访问的,需要将允许访问的方法进行显示声明,将我的配置文件修改为如下即可

<struts>
<package name="person" namespace="/person" extends="struts-default">
<action name="personAction_*" method="{1}" class="com.zjt.action.PersonAction">
<result name="index">/index.jsp</result>
<allowed-methods>getPersonByID</allowed-methods>
</action>
</package>
</struts>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐