您的位置:首页 > 产品设计 > UI/UE

session中或者request中同名字的参数会被后来者覆盖

2016-01-20 14:12 369 查看
服务器1:

public void test1() throws IOException{
ActionContext ctx = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);   
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);

ctx.getSession().put("str", "1234567890+++++++实验成功了");

String port= request.getLocalPort()+"";
System.out.println("端口号为:"+port);
response.sendRedirect("http://localhost:8080/项目1 /命名空间1/test1.action"); 
}
public String test2() throws IOException{
ActionContext ctx = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);   
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
ctx.getSession().put("str", "1234567890+++++++实验成功了???????覆盖掉就对了");

return "success";
}

服务器2

public void test1() throws IOException{
ActionContext ctx = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);   
HttpServletResponse response = (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);
response.sendRedirect("http://localhost:8080/项目2 /命名空间2/test2.action"); 

}

页面

...

<%@ taglib uri="/struts-tags" prefix="s" %>

...

${str}<br>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  session.put