2013-04-22 80 views
1

我想在每個「/ mobile/*」url上都有一個操作映射。Struts 2在特定命名空間上映射默認操作

當我把我的struts.xml如下因素:

<package name="default-mobile-action" extends="mobile-default"> 
    <action name="*.*" class="ca.tink.vitrine.webapp.action.DefaultAction">   
    ....  
    </action> 
</package> 

我「/移動/ *」的網址去的默認操作,這是正確的。 但是,當我改變這樣的映射(我添加了一個命名空間中的「/移動」):

<package name="default-mobile-action" extends="mobile-default" namespace="/mobile"> 
    <action name="*.*" class="ca.tink.vitrine.webapp.action.DefaultAction">   
    ....  
    </action> 
</package> 

現在,「/移動/ *」的網址不訪問動作(無行爲被發現...... )

這是真的不是我期望的行爲...

我錯過了什麼?

+0

見http://struts.apache.org/development/2 .x/docs/namespace-configuration.html,http://struts.apache.org/development/2.x/docs/action-configuration.html和http://struts.apache.org/development/2.x /docs/wildcard-mappings.html。 – 2013-04-22 17:15:49

+0

感興趣的人:https://www.coderanch.com/t/610039/Struts/Mapping-default-actions – Etienne 2013-04-22 18:43:25

回答

1

你可以試試這個...

的struts.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE struts PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
"http://struts.apache.org/dtds/struts-2.0.dtd"> 
<struts> 
    <include file="mobile.xml"></include> 
</struts> 

mobile.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE struts PUBLIC 
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
"http://struts.apache.org/dtds/struts-2.0.dtd"> 
<struts> 

    <package name="mobile" extends="struts-default" namespace="/mobile"> 
    </package> 
</struts> 
相關問題