主文件中的中文显示正常,但include进来的文件中的中文产生乱码?在线高分等待! 加上下面一段代码试一试<%@ page contentType="text/html;charset=gb2312" %> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 针对jsp和servlet:解决办法:第一:在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> Tomcat 4.1.12中有相应的设置吗? 呵呵, 我也碰到过这样的问题, 后来把包含的方式改了就好了;如果你用 <jsp:include page="..."/>建议改成 <%@ include file="..." %> 试试, 或者反过来试试, 我记不太清楚了 同意楼上的说法,我用的就是<%@ include file="..." %> 没有乱吗问题,不过这种,已经加载,主流内存.不便于修改. 关于集合类的问题! 关于一个算法设计,面试题(急) java还是eclipse设置问题,大虾请进 javaMail中遇到530-5.5.1 Authentication Required. 给JTextArea加滚动条问题 使用JAVA开发桌面程序有什么好的IDE可用 有没有做SWT/JFace,认识一下。 请问,如何下载JDK1.4版本,保存在哪里比较好一点。 我写了一个IDL文件,怎么用idltojava编译不成,提示错误 :--里面 jsp cache问题 指导几个java就业单位 关于操作符类型的转换。
解决办法:
第一:
在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>