java - 使用 struts2 为命名空间错误映射的操作

标签 java struts2 action-mapping

我在使用 Struts2 时遇到这个错误

There is no Action mapped for namespace [/] and action name [LoginAction] 
associated with context path [/TestBoard]. - [unknown location]    

项目上下文根 = TestBoard

这是我的 struts.xml:

<struts>
    <constant name="struts.serve.static.browserCache" value="false" />
    <constant name="struts.i18n.encoding" value="UTF-8" />
    <constant name="struts.action.extension" value="" />

    <package name="strutsPkg" extends="struts-default" namespace="/">

         <interceptors>
            <interceptor name="loginCheck" class="com.finger.fwebframework.action.LoginSessionCheck">
                <!--<param name="excludeActions">/LoginAction.action,/LoginIndexAction.action,/CUMQryCustMenuFrameListAction.action,/CUMQryCustSuppHstFrameListAction.action,/CUMQryLnkTgtSysPermtFrameListAction.action,/CUMQryRsrchInstFrameListAction.action,/CUMQrySchInfoFrameListAction.action</param>-->
                <param name="excludeActions">/LoginAction.action,/LoginIndexAction.action,\/[\w]*Frame[\w]*Action.action,\/[\w]*PopAction.action</param>
                <param name="redirectWebPage">/login.jsp</param>
            </interceptor>

            <interceptor-stack name="srcmsStack">
                <interceptor-ref name="defaultStack"/>  <!-- struts-default.xml support -->
                <interceptor-ref name="loginCheck"/>
                <interceptor-ref name="validation"> <!-- No result defined for action support -->
                    <param name="excludeMethods">input,back,cancel,browse</param>
                </interceptor-ref>
            </interceptor-stack>
        </interceptors>

        <default-interceptor-ref name="srcmsStack"/>
     </package>

    <include file="com/finger/fwebframework/struts/Struts_com.xml"></include>
</struts>

这是我的 Web.xml

    <!-- siteMesh -->
    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
    </filter>

    <!-- struts2 -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>
            <param-name>struts.i18n.encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>NoCache</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>       

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <session-config>
        <session-timeout>10</session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>
</web-app>

这是我的 login.jsp

    <%@ taglib prefix="s" uri="/struts-tags" %>

    <head>
       <meta http-equi="Content-Type" content="text/html; charset=utf-8"/>
      <script>
        $("#loginButton").click(function() {
        if ($.validate()) {
            $("#frmLogin").attr('action', 'LoginAction.action').submit();
        };
    });
      </script>
    </head>
    <body id="bdy" class="main_bg" >
         <s:form id="frmLogin">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" >
          <tr>
              <td>ID: </td>
              <td><input type = "text" name = "ID" id ="ID" /></td>
          </tr>

           <tr>
               <td>PW : </td>
               <td><input type = "password" name = "PW" id ="PW"/></td>
           </tr>

           <tr>
               <td><input type = "button" id ="loginButton" value="Log_In"/></td>
           </tr>
        </table>
     </s:form>
</body>

我做错了什么,我该如何解决这个问题?

请回答我。

最佳答案

查看错误信息 “没有为命名空间 [/] 和操作名称 [LoginAction] 映射的操作” 在你的 struts.xml 中我没有找到任何 Action 标签 你可以试试插入

<action name="LoginAction" class="com.xxx" method="">
   <result>/index.jsp</result>
</action>

关于java - 使用 struts2 为命名空间错误映射的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13505480/

相关文章:

java - 将数据从 Activity 传递到 SurfaceView

java - 从另一个应用程序接收参数

java - Struts - 在 Action 之间传递参数

google-app-engine - Struts 2 GAE 没有为命名空间映射的操作 [/]

java - Struts 2 简单成功页面不直接指向 SampleAction 类

java - PyQt/Qt 是否有类似于 MigLayout 的布局管理器?

java - Windows - 创建文件时收到警告

javascript - struts2中如何通过ajax上传文件

java - 支柱 2 : There is no Action mapped for namespace [/]

java - 通过 wifi 连接服务器和客户端套接字