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;
}
本文介绍如何使用 Struts2 的 Action 进行页面跳转,包括跳转到 JSP 页面及另一个 Action 的方法。通过配置 @Result 注解实现不同类型的跳转,并展示了如何传递参数。
6453

被折叠的 条评论
为什么被折叠?



