2009-04-17 34 views
1

我使用Struts2的,對於我的struts.xml文件包含類似的代碼:struts2.xml - 不能包含其他.xml文件

<?xml version="1.0" encoding="UTF-8" ?> 

<constant name="struts.enable.DynamicMethodInvocation" value="false" /> 
<constant name="struts.devMode" value="true" /> 

<include file="strutsAuthentication.xml"/> 

<package name="default" extends="struts-default"> 
    <interceptors> 
     <interceptor-stack name="crudStack"> 
      <interceptor-ref name="checkbox" /> 
      <interceptor-ref name="params" /> 
      <interceptor-ref name="static-params" /> 
      <interceptor-ref name="defaultStack" /> 
     </interceptor-stack> 
    </interceptors> 
</package> 

我已經在strutsAuthentication.xml中指定了所有必需的操作。這代碼:

<struts> 
<package name="authentication" extends="default" namespace="/authentication"> 
    <action name="saveCountry" class="saveCountryAction"> 
     <interceptor-ref name="defaultStack" /> 
     <result name="success">/savecountry.jsp</result> 
     <result name="error">/error.jsp</result> 
    </action> 

</package> 

當我部署我的應用程序到Tomcat,它給了我警告說:

WARN(org.apache.struts2.components.Form:308) - 無找到指定操作的配置:名稱空間中的'saveCountry':''。表單行爲默認爲「行爲」屬性的字面值。

這意味着struts.xml不能包含strutsAuthentication.xml。任何人都有解決方案?提前Thanx ...

回答

0

Got d解決方案....對於上述問題,我做了一個錯誤,從jsp頁面調用動作。因此,在調用操作類時應該包括名稱空間名稱「身份驗證」。最終的解決方案是:「authentication/saveCountry.action」。

0

作爲補充說明。我們不應該在JSP頁面中使用「xyz.action」。如果我們稍後需要或決定將.action中的url模式更改爲.do或.html等,我們必須更改所有的JSP頁面。更好的方法來組成鏈接是:

<a href="<s:url namespace="nsname" action="actionName" method="methodName"/>">Link Text</a>