欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

JSP 传递中文参数的例子

程序员文章站 2024-02-16 22:17:34
复制代码 代码如下:
复制代码 代码如下:

<?xml version="1.0" encoding="utf-8" ?>
<!doctype html public "-//wapforum//dtd xhtml mobile 1.0//en" "http://www.wapforum.org/dtd/xhtml-mobile10.dtd">
<%@ page language="java" contenttype="text/html; charset=utf-8"
pageencoding="utf-8"%>
<%@ page import="java.net.*"%>
<%
string location = "";
string locationfromrequest = request.getparameter("location");
if (null != locationfromrequest
&& (!locationfromrequest.equals(""))) {
location = java.net.urldecoder.decode(locationfromrequest,
"utf-8");
}
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
xxxxxxxxxxxxxxxxx<%=new string(location.getbytes("iso-8859-1"),"utf-8")%>
<br/>
<a href="1234.jsp?location=<%=java.net.urlencoder.encode("望京", "utf-8")%>"> 望京</a>
</html>