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";
}
}
2.struts.xml中配置url传参:
<action name="redirectTestAndparam" class="cn.itcast.action.HelloWorldAction" >
<result type="redirect">/employeeAdd1.jsp?userName=${userName}</result>
</action>
3.jsp页面中得到参数(ISO8859-1),并转成UTF-8的字符串
<%= new String(request.getParameter("userName").getBytes("ISO8859-1"),"UTF-8") %>