struts.xml中的配置
<action name="list" class="com.dev.action.HelloWorldAction" method="execute">
<result name="success" type="redirect">
<param name="location">/employeeAdd.jsp</param>
<param name="username">${username}</param>
</result>
</action>
jsp 中编码:
<%@page import="java.net.URLDecoder"%>
<%@ page language="java" import="java.util.*,java.net.URLEncoder" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'employeeAdd.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%=URLDecoder.decode(new String(request.getParameter("username").getBytes("ISO8859-1"),"UTF-8"),"UTF-8") %> //如果页面编码为gbk,这此处也为gbk吧??
<form action="/xxx">
姓名:<input type="text" name="xxx">
</form>
</body>
</html>