@Results( 中 params 怎么用

 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.     }  
posted @ 2018-02-09 11:08  ConfidentLiu  阅读(419)  评论(0编辑  收藏  举报