关于通过url传参的编码转化
1.action中先把参数转化成UTF-8的编码格式:
public class HelloWorldAction {private String msg;private String userName;public String getUserName() {return userName;}public String getMessage1() {return msg;}public String execute() throws Exception{ActionSupport xxx;userName = URLEncoder.encode("参数", "UTF-8");msg = "我的第一个struts2应用";return "success";}}
<action name="redirectTestAndparam" ><result type="redirect">/employeeAdd1.jsp?userName=${userName}</result> </action>
<%= new String(request.getParameter("userName").getBytes("ISO8859-1"),"UTF-8") %>