webwork配置中应该避免的一个错误(包名重复)

来源:互联网 发布:必达转运淘宝店真假 编辑:程序博客网 时间:2024/05/19 15:22
1)
1.1)xwork.xml如下:
<?xml version="1.0"?>
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">

<xwork>
   。。。。
   
    <include file="webwork/front/index.xml"/>
   
    <include file="webwork/front/error.xml"/>
    。。。。
   
</xwork>

1.2)index.xml如下:
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">

<xwork>


    <package name="front-core" namespace="/front" extends="front-default">

        <default-interceptor-ref name="defaultWebStack" />

        <action name="basicinfoinput" class="com.mofile.baby.web.action.signup.LoadSignupGatewayAction">
           
            <result name="success" type="freemarker">/page/signup/basicinfo_input.ftl</result>
           
        </action>
       
        <action name="basicinfoupload" class="com.mofile.baby.web.action.signup.UploadBasicInfoAction">
           
            <result name="success" type="freemarker">/page/signup/uploadfile.ftl</result>
           
        </action>
       
        。。。。。

    </package>

</xwork>

1.3)error.xml

<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">

<xwork>


    <package name="front-core" namespace="" extends="front-default">

        <action name="error" class="com.mofile.baby.web.action.ErrorAction">
           
            <result name="success" type="freemarker">/page/error/error.ftl</result>
           
        </action>
       
       

    </package>

</xwork>


2)由于粘贴拷贝的使用,使得两个子配置文件包名同名
结果由于在xwork.xml,error.xml位于index.xml之后,所以index.xml中的包被覆盖,如果访问index.xml定义的action,就会报如下错误:
2006-05-19 00:52:41,789 ERROR [http-80-Processor25] dispatcher.ServletDispatcher (ServletDispatcher.java:278) - Could not find action
com.opensymphony.xwork.config.ConfigurationException: There is no Action mapped for namespace /front and action name basicinfoinput
    at com.opensymphony.xwork.DefaultActionProxy.<init>(DefaultActionProxy.java:73)
。。。。。。

解决办法:将
error.xml改个名字就ok了