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

1、action跳转至jsp

后台:(需有get set 方法)

@SuppressWarnings("rawtypes")
	@Action(value="/loadFileList",results={
			@Result(name="attachList",location="/attach/attachList.jsp",params={"attachMemo1","${attachMemo1}"}),
			@Result(name="attachList1",location="/attach/attachList1.jsp"),
			@Result(name="attachListHT",location="/attach/attachListHT.jsp")})

前台:

<%out.println(request.getAttribute("attachMemo1")); %>

2、action跳转至action

后台:(stptuser为 action中的bo)

@Action(value="stptUserUpdate",results={
			@Result(name="stptUserEdited",params={"actionName","stptUserView","stptUserId","%{stptUser.id}"},type="redirectAction")
			})	

或者

@Result(name="success", 
  type="redirectAction", 
  location="d-list", 
  params={"id", "%{id}"} 
) 

另一个action获取

@Action(value="stptUserView",results={
			@Result(name="success",location="/userManage/stptUserView.jsp")
			})		
	public String stptUserView(){
		String id = StringUtil.getNotNullValueString(super.getServletRequest().getParameter("stptUserId"));
		this.stptUser = this.stptUserService.findStptUserById(Long.parseLong(id));
		List<ManagerVo> list = this.stptUserService.getUserInfo(id);
		List<ManagerVo> agentList = this.stptUserService.getAgentInfo(id);
		super.getServletRequest().setAttribute("voList", list);
		super.getServletRequest().setAttribute("agentList", agentList);
		return SUCCESS;
	}


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值