<%@ page contentType="text/html; charset=GBK" %>
<%
request.setCharacterEncoding("GB2312");//设置编码
%>
<%
request.setCharacterEncoding("GB2312");//设置编码
%>
解决方案 »
- (急)Hibernate缓存问题,手动向mysql插入一条数据后,界面显示不出来
- URL编码解码问题....
- jsp连接远程oracle8i出现异常,求解
- resin要指定输出文件应如何配置
- 在pluto里部署portlet,报错javax.portlet.UnavailableException: Unable to invoke portlet
- Web应用选择JavaBean和EJB的理由分别是什么?
- 查询不能执行!
- 一个servlet初级问题
- 高手帮助!!!
- 请教:servlet如何调用jsp页面或者servlet????
- 如何判断text表单中的回车?
- 怎样实现一个已知时间,在这个时间的前10分钟,用户必须修改密码?请大家给个思路?
request.setCharacterEncoding("GB2312");//设置编码
%>报出错
加上
<meta content="text/html;charset=gb2312" http-equiv="Content-Type">
还是乱码
1、
<%@page contentType="text/html;charset=gb2312"%>2、
<%@ page contentType="text/html; charset=GBK" %>
<% request.setCharacterEncoding("GB2312");//设置编码 %>
new String(str.getBytes("ISO8859_1"),"GBK");
多换几种编码试试吧!与系统有关!
试了,好象还是不行啊
第一:
1:在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
2:在servlet里面:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
3:上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null ¦ ¦s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859-1"),"gb2312");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
public static String ChineseToUnicode(String s){
try{
if(s==null ¦ ¦s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859-1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}