<span style="font-size:18px;"> @Override
public String execute()
throws Exception
{
list = new ArrayList<String>(2);
list.add(name1);
list.add(name2);
ActionContext actionContext = ActionContext.getContext();
Map session = actionContext.getSession();
session.put("list", list);
<span style="color:#ff0000;">HttpServletRequest request = ServletActionContext.getRequest(); </span>
request.setAttribute("listrequest", list);
return SUCCESS;
} </span>
本文介绍了一个Struts2应用中的示例代码,展示了如何在Action类中使用@Override注解重写execute方法,并通过该方法设置Session与Request属性。具体操作包括创建字符串列表并将其存入Session及Request中。
126

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



