码迷,mamicode.com
首页 > 其他好文 > 详细

@Results( 中 params 怎么用

时间:2018-02-09 14:57:40      阅读:333      评论:0      收藏:0      [点我收藏+]

标签:request   date   values   pop   copy   key   strong   attr   htm   

 http://blog.csdn.net/z69183787/article/details/16342553

struts2的@Result annotation 如何添加params,并且在页面取值

1、action跳转至jsp

后台:(需有get set 方法)

 

[java] view plain copy
 
  1. @SuppressWarnings("rawtypes")  
  2.     @Action(value="/loadFileList",results={  
  3.             @Result(name="attachList",location="/attach/attachList.jsp",params={"attachMemo1","${attachMemo1}"}),  
  4.             @Result(name="attachList1",location="/attach/attachList1.jsp"),  
  5.             @Result(name="attachListHT",location="/attach/attachListHT.jsp")})  


前台:

 

 

[html] view plain copy
 
  1. <%out.println(request.getAttribute("attachMemo1")); %>  


2、action跳转至action

 

后台:(stptuser为 action中的bo)

 

[java] view plain copy
 
  1. @Action(value="stptUserUpdate",results={  
  2.             @Result(name="stptUserEdited",params={"actionName","stptUserView","stptUserId","%{stptUser.id}"},type="redirectAction")  
  3.             })    


或者

 

 

[java] view plain copy
 
  1. @Result(name="success",   
  2.   type="redirectAction",   
  3.   location="d-list",   
  4.   params={"id", "%{id}"}   
  5. )   


另一个action获取

 

 

[java] view plain copy
 
    1. @Action(value="stptUserView",results={  
    2.             @Result(name="success",location="/userManage/stptUserView.jsp")  
    3.             })        
    4.     public String stptUserView(){  
    5.         String id = StringUtil.getNotNullValueString(super.getServletRequest().getParameter("stptUserId"));  
    6.         this.stptUser = this.stptUserService.findStptUserById(Long.parseLong(id));  
    7.         List<ManagerVo> list = this.stptUserService.getUserInfo(id);  
    8.         List<ManagerVo> agentList = this.stptUserService.getAgentInfo(id);  
    9.         super.getServletRequest().setAttribute("voList", list);  
    10.         super.getServletRequest().setAttribute("agentList", agentList);  
    11.         return SUCCESS;  
    12.     }  

@Results( 中 params 怎么用

标签:request   date   values   pop   copy   key   strong   attr   htm   

原文地址:https://www.cnblogs.com/ConfidentLiu/p/8434662.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!