2

我在使用 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>

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

请回答我。

4

1 回答 1

1

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

<action name="LoginAction" class="com.xxx" method="">
   <result>/index.jsp</result>
</action>
于 2012-11-22T05:24:15.157 回答