现在的位置: 首页 > 综合 > 正文

Struts2中action重定向跳转到jsp参数中带有中文

2018年02月13日 ⁄ 综合 ⁄ 共 1138字 ⁄ 字号 评论关闭

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>

<%@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>
  	error:<%=URLDecoder.decode(new String(request.getParameter("username").getBytes("ISO8859-1"),"UTF-8"),"UTF-8") %>
    <form action="/xxx">
    	姓名:<input type="text" name="xxx">
    </form>
  </body>
</html>

抱歉!评论已关闭.