问题描述
Actionpackagestruts2TestPortlet.action;importjava.util.ArrayList;importjava.util.List;importjava.util.Map;importstruts2TestPortlet.bean.User;importcom.opensymphony.xwork2.ActionContext;importcom.opensymphony.xwork2.ActionSupport;publicclassLoginextendsActionSupport{privateUseruser;publicUsergetUser(){returnuser;}publicvoidsetUser(Useruser){this.user=user;}publicStringlogin(){Maprequest=(Map)ActionContext.getContext().get("request");Mapsession=ActionContext.getContext().getSession();List<User>list=newArrayList<User>();System.out.println("jinlogin");Useru=newUser();u.setUsername("du");u.setPassword("pwd");list.add(user);list.add(u);session.put("user",user);request.put("ulist",list);if(user.getUsername().equals("du")&&user.getPassword().equals("pwd")){return"success";}else{return"fail";}}}jsp<%@pagelanguage="java"contentType="text/html;charset=GB18030"pageEncoding="GB18030"session="false"%><%@tagliburi="http://java.sun.com/portlet"prefix="portlet"%><portlet:defineObjects/><%@tagliburi="/struts-tags"prefix="ss"%><%@tagliburi="http://java.sun.com/jstl/core"prefix="c"%><p>no</p>${session.user.username}<br/>${session.user.password}<br/><ss:iteratorvar="list"value="#request.ulist">name=<ss:propertyvalue="username"/>pass=<ss:propertyvalue="password"/></ss:iterator><ss:iteratorvar="list"value="#request.ulist">pass=${password}name=${username}</ss:iterator>action能取到jsp输入的值但是跳转后的jsp取不到request的值要怎么才能取得request的值呢