Struts2中There is no Action mapped for namespace错误解决方法

1.我的原有配置

jsp表单提交路径

<form class="layui-form" id="form" action="${ctx }/membersLogin/membersLoginAction!membersLogin.action">
    ............
</form>

struts2拦截配置

    <package name="default" extends="struts-default" namespace="/membersLogin" strict-method-invocation="false">
        <action name="membersLoginAction" class="seventykg.web.MembersLoginAction">
            <result name="login_success">/index.jsp</result>
            <result name="login_fail">/login_fail.jsp</result>
        </action>
    </package>

2.按常理来说是没问题的

但是每次提交表单的时候报错如下:

There is no Action mapped for namespace。。。。。。。。。

3.百度搜了一下各种解决方法,都不是我想要的,无奈自己看了一下struts.xml配置文件,发现有一个地方叫:

 

    <!-- 是否开启动态方法调用 -->
    <constant name="struts.enable.DynamicMethodInvocation" value="true"/>

 

当这个value="false"的时候,是不支持(${ctx }/membersLogin/membersLoginAction!membersLogin.action)这样带有方法(membersLogin)的路径的,仅仅支持(${ctx }/membersLogin/membersLoginAction)这样的,方法的话需要写到配置文件中

<package name="default" extends="struts-default" namespace="/membersLogin" strict-method-invocation="false">
        <action name="membersLoginAction" class="membersLoginAction" method="membersLogin">
            <result name="login_success">/index.jsp</result>
            <result name="login_fail">/login_fail.jsp</result>
        </action>
</package>

改成true即可解决问题

=====================================================================================

今天特来补充一下还是这个异常问题:

在同一个struts配置文件中,package标签的name属性不能全为default,若有多个,必须给name起名字,若不然还是会报这个异常:

There is no Action mapped for namespace [/membersLogin] and action name [membersLoginAction] associated with context path...

 

QQ交流群4060038

本文作者:在谷歌上百度

本文链接:https://www.cnblogs.com/zhangjianbing/p/8275384.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   在谷歌上百度  阅读(14479)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开