jsp中最好写<%@ page language="java" contentType="text/html; charset=gb2312"%>,这个指定了你的页面显示的charset,不然,即使你在html里面指定也是没有用的
解决方案 »
- dao连接不到数据库
- Struts2 验证的错误信息返回到action的问题
- 请教搞手!
- TXT、DOC、RAR、PPT、PDF、ZIP上传类型问题!
- 想用自己的的电脑做邮件服务器!不知道web方式的怎么弄啊
- xp下servlet连接oracle出现的错误。
- 如何进行如下输出RS记录?
- tomcat的类路径配置问题!!!100分
- ******"Servlet根据JSP视图的需求生成JavaBeans的实例并输出给JSP环境"如何实现上面这句话的效果??*******
- 请问各位大虾,如何使用jsp页面里的butten触发调用bean或者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");
-------------------------
我流落在凄凉的世界里-孤苦伶仃
我过着动荡无助的生活-四处漂泊