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也不见得好用,或者经过的工序不一样也不一定嘛。 jsf的错误,拜托看一下!!! js在函数中如何获得Servlet响应的值 JDIC中的WebBrowser 怎么设置Cookie el表达式+标准标签库如何调用一个类里面的方法 我遇到个tomcat与oracle的诡异问题,难道是端口有冲突,高手来看看! 现在一般的大公司都有什么做JSP的服务器啊? tomcat问题,急!! 本人html知识浅薄,求教一个表单问题! 急救!!!!HELP!!!! 如何用 Jsp 调出保存对话框, 同时将网页保存为文本格式, 回答一个问题就有分 请问谁有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");
-------------------------
我流落在凄凉的世界里-孤苦伶仃
我过着动荡无助的生活-四处漂泊