解决办法:
第一:
在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
上面的如果在不行就用如下的方法在数据入库前进行调用:
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;
}
}
3:)解决weblogic/webshpere中文问题:
在web.xml文件中需要配置中文环境。r如下:
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>GB2312</param-value>
</context-param>
用这些办法一定能解决你的问题。
第一:
在jsp页面加入:
<%@ page contentType="text/html; charset=gb2312" %>
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
上面的如果在不行就用如下的方法在数据入库前进行调用:
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;
}
}
3:)解决weblogic/webshpere中文问题:
在web.xml文件中需要配置中文环境。r如下:
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>GB2312</param-value>
</context-param>
用这些办法一定能解决你的问题。
解决方案 »
- ActiveMQ遇到的问题
- finally块中的代码一定会执行吗?
- 有谁知道什么是javaEE?
- 为何类中的一个参数为bigdecimal,页面为何变成科学计算了?
- 关于WAP的问题
- 谁有多余的QQ号 批量给我点~!!!
- struts2中通配符与默认action冲突!
- 莱鸟问题,我用jdbc连oracle,去oracle网站确发现一堆jdbc,每个版本的oracle都有自己的jdbc..
- 郑重承诺,由于时间要求较紧,java rmi的问题,我愿意再加100分,江湖救急大家帮忙了!!
- springboot整合mybatis项目运行是报错BeanCreationException
- 请问一个基础问题,谢谢!
- jboss可否降级?
if(s==null ¦ ¦s.equals("")) return "";