zoukankan      html  css  js  c++  java
  • result 相关

    1.dispatcher

    2.redirect

    3.chain

    4.redirectAction

    5.freemarker

    6.httpheader

    7.stream

    8.velocity

    9.xslt

    10.plaintext

    11.tiles

    常用的是前四种

    <package name="resultType" namespace="/r" extends="struts-default">
    
            <action name="r1">
                <!-- result 不指定type默认为dispatcher 运用服务器跳转 forword到jsp压面 显示action地址 -->
                <result type="dispatcher">/r1.jsp</result>
            </action>
    
            <action name="r2">
                <!-- 客户端跳转 显示jsp地址 -->
                <result type="redirect">/r2.jsp</result>
            </action>
    
            <!-- 同r1 forword到另外一个action -->
            <action name="r3">
                <result type="chain">r1</result>
            </action>
    
            <!-- 同r2 -->
            <action name="r4">
                <result type="redirectAction">r2</result>
            </action>
        </package>
    
        <package name="user2" namespace="/user2" extends="struts-default">
            <!-- 其他包可以用extends继承 -->
            <global-results>
                <result name="mainpage">/main.jsp</result>
            </global-results>
    
            <action name="user2" class="com.ouc.wkp.action.UserAction2">
                <result name="success">/r1.jsp</result>
                <result name="error">/r2.jsp</result>
            </action>
        </package>
    
        <package name="user3" namespace="/user3" extends="struts-default">
            <action name="user3" class="com.ouc.wkp.action.UserAction3">
                <result>${r}</result>
            </action>
        </package>
    struts.xml
    package com.ouc.wkp.action;
    
    import com.opensymphony.xwork2.ActionSupport;
    
    public class UserAction2 extends ActionSupport {
        private int type;
    
        public int getType() {
            return type;
        }
    
        public void setType(int type) {
            this.type = type;
        }
    
        @Override
        public String execute() throws Exception {
            if(type==1){
                return "success";
            }else if(type==2){
                return "error";
            }else{
                return "mainpage";
            }
        }
    }
    UserAction2
    动态结果集,在action中保存一个属性,存储具体的结果location
    package com.ouc.wkp.action;
    
    import com.opensymphony.xwork2.ActionSupport;
    
    public class UserAction3 extends ActionSupport {
        private int type;
        private String r;
    
        public int getType() {
            return type;
        }
    
        public void setType(int type) {
            this.type = type;
        }
    
        public String getR() {
            return r;
        }
    
        public void setR(String r) {
            this.r = r;
        }
    
        @Override
        public String execute() throws Exception {
            if (type == 1) {
                r = "/r1.jsp";
            } else if (type == 2) {
                r = "/r2.jsp";
            } else {
                r = "/main.jsp";
            }
            return SUCCESS;
        }
    }
    UserAction3

    使用redirect跳转时是两次request,需要传参

    <!-- <result type="redirect">/xxx.jsp?t=${type}</result> -->

    前台通过<s:property value="#parameters.t"/>从actioncontext里面取

  • 相关阅读:
    w10更新
    java.lang.Integer cannot be cast to java.math.BigDecimal
    加法add 乘法multiply
    iterator,hasNext,next
    购物车全部数据,带商品信息
    ERRORinit datasource error, url: jdbc:mysql://localhost:3306/xxxxxx?useUnicode=true&characterEncoding=gbk&serverTimezone=GMT&useSSL=false
    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:
    创建一个场景
    window系统已发布,等待更新
    [转]向量(矩阵)范式理解(0范式,1范式,2范式,无穷范式)
  • 原文地址:https://www.cnblogs.com/wangkaipeng/p/5735137.html
Copyright © 2011-2022 走看看