当前位置:编程学习 > JS >>

JSP之中文乱码解决方法实例代码

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>
补充:Web开发 , Jsp ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,