2012-11-22 82 views
2

我收到此錯誤與Struts2的動作映射名稱空間誤差與struts2的

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

項目上下文根=測試臺

這裏是我的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> 

這裏是我的網頁。 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> 

我在做什麼錯,我該如何解決這個問題?

請回答我。

+0

那麼這個包裏沒有動作映射,除非它在Struts_com.xml中,但是沒有提供,或者你使用的是struts2-conventions插件。嘗試在該xml中通過該包名稱配置該操作:http://struts.apache.org/2.1.6/docs/action-configuration.html – Quaternion

回答

1

看到錯誤消息 「沒有映射爲命名空間操作[/]和動作名稱[在LoginAction]」 在struts.xml中我沒有找到任何動作標籤 你可以嘗試插入

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

是的。對不起。行動在這裏。

+0

因此,請顯示您的「Struts_com.xml」文件。 –

相關問題