webWork全局result实例应用

为了应付目前已开发大量的一些action的现有情况,同时也要解决以前工作不要去改动,又实现一些新功能, 查阅了一下资料。

基础思路如下:

 

在现有已方平台基础上的最基础的baseAction中加入基础方法,同时在全局继承的基础package,加入基础result

类型为“重定向”。返回值由基础action的变量动态生成。然后基于这些,就可以实现很灵活的操作,又不需要去重构旧代码

 

 

<package name="mydefault" extends="webwork-default">
		<interceptors>
			<interceptor-stack name="coralStack">
				<interceptor-ref name="exception"/>
                <interceptor-ref name="alias"/>
                <interceptor-ref name="servlet-config"/>
                <interceptor-ref name="prepare"/>
                <interceptor-ref name="i18n"/>
                <interceptor-ref name="chain"/>
                <interceptor-ref name="debugging"/>
                <interceptor-ref name="model-driven"/>
                <interceptor-ref name="fileUpload"/>
                <interceptor-ref name="static-params"/>
                <interceptor-ref name="params"/>
                <interceptor-ref name="conversionError"/>
                <interceptor-ref name="validation">
                    <param name="excludeMethods">delete,edit,execute,list,selectlist</param>
                </interceptor-ref>
                <interceptor-ref name="workflow">
                    <param name="excludeMethods">delete,edit,execute,list,selectlist</param>
                </interceptor-ref>
        	</interceptor-stack>
        </interceptors>
		<default-interceptor-ref name="coralStack" />
		<global-results>
            <result name="error">/errors/error.jsp</result>
            <!-- 全局返回的 -->
            <result name="_toPage" type="redirect-action">${_toPageUrl}</result>

        </global-results>
        <global-exception-mappings>
            <exception-mapping result="error" exception="java.lang.Throwable"/>
        </global-exception-mappings>
        
</package>

 

 

 

/**
 * 最基础的一个Controller,供继承
 * 
 */

abstract public class BaseAction extends ActionSupport{
	
	/**
	 * 返回名
	 */
	protected static final String RESULT_TOPAGE = "_toPage";
	
	private String _toPageUrl;
	
	public String get_toPageUrl() {
		return _toPageUrl;
	}

	public void set_toPageUrl(String pageUrl) {
		_toPageUrl = pageUrl;
	}

	/**
	 * 跳转的基础方法,在公共配置上也对应的配置上了公共返回名
	 * @return
	 */
	public String toPageUrl(){
		//测试 ../这个操作非常有用,因为webwork result中是相对路径,通过..可以调整路径,实现访问另一个模块
		//this._toPageUrl = "../admin/resourceIndex.do?flag=1.00";
		
		return RESULT_TOPAGE;
	}

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值