JSP之中文乱码解决方法实例代码
来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 11:37 点击:次
JSP之中文乱码解决方法实例代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
!String getString(String param) {
String tmp;
try {
byte[] strBytes = param.getBytes("ISO8859-1");
tmp = new String(strBytes, "GBK");
return tmp;
} catch (Exception e) {
return null;
}
}
%>
<%
String uname = getString(request.getParameter("uname"));
%>
<html>
<head><title>样本</title></head>
<body>
姓名:<%=uname %>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
!String getString(String param) {
String tmp;
try {
byte[] strBytes = param.getBytes("ISO8859-1");
tmp = new String(strBytes, "GBK");
return tmp;
} catch (Exception e) {
return null;
}
}
%>
<%
String uname = getString(request.getParameter("uname"));
%>
<html>
<head><title>样本</title></head>
<body>
姓名:<%=uname %>
</body>
</html>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>