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>
    

      

      

  • 相关阅读:
    leetcode 268. Missing Number
    DBSCAN
    python二维数组初始化
    leetcode 661. Image Smoother
    leetcode 599. Minimum Index Sum of Two Lists
    Python中的sort() key含义
    leetcode 447. Number of Boomerangs
    leetcode 697. Degree of an Array
    滴滴快车奖励政策,高峰奖励,翻倍奖励,按成交率,指派单数分级(1月3日)
    北京Uber优步司机奖励政策(1月2日)
  • 原文地址:https://www.cnblogs.com/wujixing/p/5202906.html
Copyright © 2011-2022 走看看