zoukankan      html  css  js  c++  java
  • Struts2--带参数的结果集

    带参数的结果集:

    配置文件: <result type="redirect">/user_success.jsp?t=${type}</result>

    jsp调用 :

    from valuestack: <s:property value="t"/><br/>   //取不到,因为客户端跳转后 以前action的值都没有了.
    from actioncontext: <s:property value="#parameters.t"/>

    1. jsp显示文件:]

    <ol>
    	<li><a href="user/user?type=1">传参数</a></li>
    </ol>
    

    2. struts.xml配置文件:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
    
    <struts>
        <constant name="struts.devMode" value="true" />
        <package name="user" namespace="/user" extends="struts-default">
        	
    	    <action name="user" class="com.bjsxt.struts2.user.action.UserAction">
    	    	<result type="redirect">/user_success.jsp?t=${type}</result>
    	    </action>	    
        </package>    	
    </struts>
    

    3. action文件:

    package com.bjsxt.struts2.user.action;
    
    import com.opensymphony.xwork2.ActionSupport;
    
    public class UserAction extends ActionSupport {
    	private int type;
    	
    	public int getType() {
    		return type;
    	}
    	public void setType(int type) {
    		this.type = type;
    	}
    	@Override
    	public String execute() throws Exception {
    		return "success";
    	}
    
    }
    

      

     

    4. user_success.jsp:

    <body>
    	User Success!
    	from valuestack: <s:property value="t"/><br/>  取不出来, 因为客户端跳转, 值栈已清空
    	from actioncontext: <s:property value="#parameters.t"/>
    	<s:debug></s:debug>
    </body>
    

      

      

  • 相关阅读:
    DTOJ #3328. 开箱子(unboxing)
    dtoi4649 光明
    dtoi4539「TJOI / HEOI2016」序列
    dtoi3031 交错和查询 (sum)
    dtoi4375「BJOI2019」删数
    dtoi4266 exchange
    dtoi4680 红黑兔
    dtoi1363 楼房重建 (rebuild)
    dtoi1927 [ONTAK2010]Peaks加强版
    dtoi4538 「TJOI / HEOI2016」排序
  • 原文地址:https://www.cnblogs.com/wujixing/p/5202906.html
Copyright © 2011-2022 走看看