关于WebWork

来源:互联网 发布:大数据 学什么语言 编辑:程序博客网 时间:2024/06/06 04:08

使用Webwork2 作为MVC的要注意的配置项。

1、web.xml   

<filter>
    
<filter-name>webwork</filter-name>
    
<filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
    
<filter-name>webwork</filter-name>
    
<url-pattern>/*</url-pattern>
</filter-mapping>

2、xwork.xml

关于default-action-ref--如果你在xwork.xml里面配置了default-action-ref,那么当xwork中没有找到对应的action时,默认就会调用default-action-ref指定的action。但是要注意,一般一个package内配置一个,如果配置多个,就无法预测结果了。

xwork配置样例

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

<xwork>
    
<include file="webwork-default.xml"/>

    
<package name="default" extends="webwork-default">

        
<default-action-ref name="home" />

        
<action name="home" class="example.HomeAction">
            
<result>/WEB-INF/pages/home.jsp</result>
        
</action>

    
</package>
</xwork>

注意:上面的result的name属性被省略时,WebWork会认为它是"SUCCESS"。

3、webwork.properties

参考:webwork.properties的完整翻译