简体   繁体   中英

Action mapped for namespace error with struts2

I am getting this error with Struts2

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

Project context root = TestBoard

Here's my 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>

Here's my 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>

Here's my 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>

What am I doing wrong and how can I solve this problem?

Please answer me.

see the error message "There is no Action mapped for namespace [/] and action name [LoginAction] " in your struts.xml I didn't find any action label you can try insert

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM