|
test1.jsp頁面:
復制代碼 代碼如下:
<%@ page language="Java" import="Java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'test1.jsp' starting page</title>
</head>
<body>
<a href="test2.jsp?name=<%=Java.NET.URLEncoder.encode("王云鵬","utf-8") %>">test2.jsp</a>
</body>
</html>
test2.jsp頁面:
復制代碼 代碼如下:
<%@ page language="Java" import="Java.util.*" pageEncoding="utf-8"%>
<%
String name = request.getParameter("name");//get tomcat 's string formatter is ISO-8859-1
byte[] names = Java.NET.URLEncoder.encode(name,"ISO-8859-1").getBytes();//get inner tomcat 's byte content
name = new String(names,"utf-8");//get url 's string formatter is utf-8
name = Java.NET.URLDecoder.decode(name,"utf-8");//decode string to chinese word
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'test2.jsp' starting page</title>
</head>
<body>
Name:<%=name %>
</body>
</html>
jsp技術:jsp地址欄傳中文顯示亂碼解決方法分享,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。