jsp中如果不写<%@ page language="java" contentType="text/html; charset=gb2312"%>显示乱码 jsp中最好写<%@ page language="java" contentType="text/html; charset=gb2312"%>,这个指定了你的页面显示的charset,不然,即使你在html里面指定也是没有用的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 哎,关键是涉及到一些特殊字符,gb2312显示不了的,所以想用tomcat默认的,iso8859_1,这样页面显示就成了问题。 在你页面的首行加入<%@ page language="java" contentType="text/html; charset=gb2312"%> 或者这个?<%@ page language="java" contentType="text/html; charset=GBK"%> 可以试试下面的://从HTTP请求的头信息中获取客户端的语言设置String clientLanguage = request.getHeader("Accept-Language"); //简体中文浏览器 if ( clientLanguage.equals("zh-cn") ) { request.setCharacterEncoding("GBK"); response.setContentType("text/html; charset=GBK"); } //繁体中文浏览器 else if ( clientLanguage.equals("zh-tw") ) { request.setCharacterEncoding("BIG5"); response.setContentType("text/html; charset=BIG5"); } //日文浏览器 else if ( clientLanguage.equals("jp") ) { request.setCharacterEncoding("SJIS"); response.setContentType("text/html; charset=SJIS"); } //缺省认为是英文浏览器 else { request.setCharacterEncoding("ISO-8859-1"); response.setContentType("text/html; charset=ISO-8859-1"); } ... //设置好request的解码方式和response的编码方式后,进行后续的操作。 线索提供,用多语言支持配置文件好了,写xml,哈哈,我没用过 奇怪,我servlet中request.setCharacterEncoding("GBK"); 在jsp中?<%@ page language="java" contentType="text/html; charset=GBK"%>结果数据提交后居然是乱码。我跟踪了一下,在servlet中经过gbk转换后就变成乱码了,这是怎么回事? 除了在头文件中写<%@ page language="java" contentType="text/html; charset=gb2312"%>得到变量还要这样写:肯定不会有乱码问题:title = new String(request.getParameter("title").getBytes("ISO8859-1"),"GB2312"); 我用resin不写那句,ie会显示jsp的原代码。-------------------------我流落在凄凉的世界里-孤苦伶仃我过着动荡无助的生活-四处漂泊 GBK也不见得好用,或者经过的工序不一样也不一定嘛。 请问为什么我从数据库里调用的文字中有些变成问号了 ckeditor3.0.1 难道真如我用的那么难用吗? 页面刚加载时判断radio按钮是否选中 小菜,刚学JSP有问题?性别处理! 急需支持中文文件名的jspSmartUpload一份,好心的兄弟请发一份给我! 问个打开文件(下载)的问题 md5加密 java和.net为什么结果不一样啊 回车自动提交???????????? 求jsp报错解释 servlet的运行环境? 请问谁有JRUN的正式版? 初来JSP,请多关照,谁有EJB的小例子,最好是JBOSS+ORACLE
String clientLanguage = request.getHeader("Accept-Language");
//简体中文浏览器
if ( clientLanguage.equals("zh-cn") ) {
request.setCharacterEncoding("GBK");
response.setContentType("text/html; charset=GBK");
}
//繁体中文浏览器
else if ( clientLanguage.equals("zh-tw") ) {
request.setCharacterEncoding("BIG5");
response.setContentType("text/html; charset=BIG5");
}
//日文浏览器
else if ( clientLanguage.equals("jp") ) {
request.setCharacterEncoding("SJIS");
response.setContentType("text/html; charset=SJIS");
}
//缺省认为是英文浏览器
else {
request.setCharacterEncoding("ISO-8859-1");
response.setContentType("text/html; charset=ISO-8859-1");
} ...
//设置好request的解码方式和response的编码方式后,进行后续的操作。
哈哈,我没用过
在jsp中?<%@ page language="java" contentType="text/html; charset=GBK"%>
结果数据提交后居然是乱码。
我跟踪了一下,在servlet中经过gbk转换后就变成乱码了,这是怎么回事?
<%@ page language="java" contentType="text/html; charset=gb2312"%>
得到变量还要这样写:肯定不会有乱码问题:title = new String(request.getParameter("title").getBytes("ISO8859-1"),"GB2312");
-------------------------
我流落在凄凉的世界里-孤苦伶仃
我过着动荡无助的生活-四处漂泊