借朋友ID问问题,JSP中文问题 <%response.setContentType("text/html;charset=gb2312"); request.setCharacterEncoding("gb2312");%>兄弟,加上这个试试。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ page contentType="text/html; charset=gb2312" %> 这些我都试过了,<%@ page contentType="text/html; charset=gb2312" %>我还试了n种组合比如<%@ page contentType="text/html; charset=GBK" %>什么的两个页面排列组合,还是不行啊不过还是很感谢你们 改web.xml的内码设置,如utf-8改为gb2312. 写一个函数,用于转换中文就行了,到时哪里需要用到中文就用这个函数把它包装了,需要用到GBK编码? 插入以下的语句isnull = new String(isnull.getBytes("iso-8859-1"),"GBK");即可但是jackal123 (卖女孩的小火柴) 你的结果也不应该是null,而应该是”???“ 这是一个完整函数,希望有用package leaveword;/** * Title: leava * Description: 字符串转换 * Copyright: Copyright (c) 2003 * Company: 202 * @author lmt * @version 1.0 */public class Getstr { public Getstr() { } /** *将前台字符标准ISO8859_1转化为数据库字符标准GB2312 *@param GB 返回的字符串 */ public String getGBstr(String Str){ String GB=Str; try{ GB = new String(GB.getBytes("ISO8859_1"), "GBK"); GB = new String(GB.getBytes("GBK"), "GB2312"); } catch (Exception e) { System.out.println(e); } return GB; } /** *将数据库字符标准GB2312转化为前台字符标准ISO8859_1 *@param ISO 返回的字符串 */ public String getISOstr(String Str){ String ISO=Str ; try{ ISO = new String(ISO.getBytes("GB2312"), "GBK"); ISO = new String(ISO.getBytes("GBK"), "ISO8859_1"); } catch (Exception e) { System.out.println(e); } return ISO; } /** *将前台字符标准ISO8859_1转化为页面GBK *@param GBK 返回的字符串 */ public String getGBK(String Str){ String GBK=Str; try{ GBK=new String(GBK.getBytes("ISO8859_1"), "GBK"); } catch (Exception e) { System.out.println(e); } return GBK; }} 用get方法直接传中文一般都要出错。不出错的好象只有iis。所以你用get方法传中文不太合适 <%response.setContentType("text/html;charset=gb2312"); request.setCharacterEncoding("gb2312");%> 在String isnull=request.getParameter("isnull");加一条语句试试: request.setCharacterEncoding("GBK"); 回复人: zhuxr2003(zxr) ( ) 信誉:100 2003-05-17 11:12:00 得分:0 改web.xml的内码设置,如utf-8改为gb2312. 请问,这位大哥指的内码设置我没找到,内码设置的格式是什么样的呢? 我也遇到了这样的问题,用get方式传中文的确有问题,我最后用的是session来传递要传的数据。还有一个方法就是使用request.setAttribute(),也许有用,也就是RequestDispatcher dp=getServletContext().getRequestDispatcher("/error/input_error.jsp");request.setAttribute("isnull","日期");dp.forward(request,response);然后再error.jsp中用request.getAttribute()来得到!试一试吧! 我感觉我的问题不是出在getParameter()上,因为用form传时,getParameter可以得到中文,没问题,就是在jsp:forward传时不行,或用“http://202.113.184.40/test/2.jsp?isnull=中文”也不行 对啊,用form的时候是post方式,用?isnull=中文和用forward时设置param都属于get方式,可以肯定的是用java的程序方式传递get方式的参数都存在这个问题, 我在jsp和servlet中用response.sendRedircet(url)时url中的中文也无法被浏览器识别,应该是j2ee这个平台等问题了吧! frameElement jsp如何操作sqlserver存储过程 SQL的问题 求和出现异常问题,高手请进!!! 有人帮我看下这个错误提示是什么意思? 关于JSP中应用Javabean中的classpath问题???? 我该怎么办??? 有关javamail发邮件问题,如何指定发件人??? 菜鳥請教大俠們 : 請問怎麼實現一個數據庫的連結池啊 ? extjs菜鸟,网上查到的一段代码,请大虾们指点一二 请问在JSP页面中能否利用FTPclient 上传文件 很郁闷的问题~!
<%@ page contentType="text/html; charset=gb2312" %>我还试了n种组合
比如<%@ page contentType="text/html; charset=GBK" %>什么的
两个页面排列组合,还是不行啊不过还是很感谢你们
需要用到GBK编码?
isnull = new String(isnull.getBytes("iso-8859-1"),"GBK");
即可但是jackal123 (卖女孩的小火柴)
你的结果也不应该是null,而应该是”???“
package leaveword;/**
* Title: leava
* Description: 字符串转换
* Copyright: Copyright (c) 2003
* Company: 202
* @author lmt
* @version 1.0
*/public class Getstr { public Getstr() {
}
/**
*将前台字符标准ISO8859_1转化为数据库字符标准GB2312
*@param GB 返回的字符串
*/
public String getGBstr(String Str){
String GB=Str;
try{ GB = new String(GB.getBytes("ISO8859_1"), "GBK");
GB = new String(GB.getBytes("GBK"), "GB2312");
}
catch (Exception e)
{
System.out.println(e);
}
return GB;
}
/**
*将数据库字符标准GB2312转化为前台字符标准ISO8859_1
*@param ISO 返回的字符串
*/
public String getISOstr(String Str){
String ISO=Str ;
try{ ISO = new String(ISO.getBytes("GB2312"), "GBK");
ISO = new String(ISO.getBytes("GBK"), "ISO8859_1");
}
catch (Exception e)
{
System.out.println(e);
}
return ISO;
} /**
*将前台字符标准ISO8859_1转化为页面GBK
*@param GBK 返回的字符串
*/
public String getGBK(String Str){
String GBK=Str;
try{
GBK=new String(GBK.getBytes("ISO8859_1"), "GBK");
}
catch (Exception e)
{
System.out.println(e);
}
return GBK;
}
}
request.setCharacterEncoding("gb2312");%>
在String isnull=request.getParameter("isnull");
加一条语句试试:
request.setCharacterEncoding("GBK");
改web.xml的内码设置,如utf-8改为gb2312.
请问,这位大哥指的内码设置我没找到,内码设置的格式是什么样的呢?
request.setAttribute("isnull","日期");
dp.forward(request,response);
然后再error.jsp中用request.getAttribute()来得到!
试一试吧!