Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Application Server » Tomcat  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 tomcat5.0.28又来玩不支持中文了
alin_ass





发贴: 183
积分: 0
于 2004-09-10 23:24 user profilesend a private message to usersend email to alin_asssearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
同一个app在5.0.27下正常,在5.0.28下乱码

已经指定<meta http-equiv="Content-Type" content="text/html; charset=gb2312">



叫我包子
作者 Re:tomcat5.0.28又来玩不支持中文了 [Re:alin_ass]
logix

莫等闲,白了少年头



发贴: 54
积分: 0
于 2004-09-15 20:37 user profilesend a private message to usersend email to logixsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
还需要
<%@ page contentType="text/html;charset=GB2312" %>
再试试



作者 Re:tomcat5.0.28又来玩不支持中文了 [Re:alin_ass]
alin_ass





发贴: 183
积分: 0
于 2004-09-15 20:41 user profilesend a private message to usersend email to alin_asssearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
哎,这个偶不管,关键是27可以用,同样28就不行了,我一般都是在include.jsp里
<%@ page session="false"%>
<%@ page pageEncoding="gb2312" contentType="text/html;charset=gb2312"%>



叫我包子
作者 Re:tomcat5.0.28又来玩不支持中文了 [Re:alin_ass]
scottlai



元老


发贴: 451
积分: 366
于 2004-09-16 05:58 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
被include 的JSP的ENCODING對PARENT JSP 無效!!

alin_ass wrote:
哎,这个偶不管,关键是27可以用,同样28就不行了,我一般都是在include.jsp里
<%@ page session="false"%>
<%@ page pageEncoding="gb2312" contentType="text/html;charset=gb2312"%>



作者 Re:tomcat5.0.28又来玩不支持中文了 [Re:alin_ass]
gegew





发贴: 1
积分: 0
于 2004-09-16 12:03 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
原因:
1 tomcat的j2ee实现对表单提交即post方式提示时处理参数采用缺省的iso-8859-1来处理
2 tomcat对get方式提交的请求对query-string 处理时采用了和post方法不一样的处理方式。(与tomcat4不一样,所以设置setCharacterEncoding(“gbk”))不起作用。

解决办法:

首先所有的jsp文件都加上:

1 实现一个Filter.设置处理字符集为GBK。(在tomcat的webapps/servlet-examples目录有一个完整的例子。请参考web.xml和SetCharacterEncodingFilter的配置。)

1)只要把%TOMCAT安装目录%/ webapps\servlets-examples\WEB-INF\classes\filters\SetCharacterEncodingFilter.class文件拷到你的webapp目录/filters下,如果没有filters目录,就创建一个。
2)在你的web.xml里加入如下几行:

<filter> <filter-name>Set Character Encoding</filter-name> <filter-class>filters.SetCharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>GBK</param-value> </init-param> </filter> <filter-mapping> <filter-name>Set Character Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

3)完成.

2 get方式的解决办法
1) 打开tomcat的server.xml文件,找到区块,加入如下一行:
URIEncoding=”GBK”
完整的应如下:

<Connector port="80" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="GBK"/>

2)重启tomcat,一切OK。

执行如下jsp页页测试是否成功

<%@ page contentType="text/html;charset=gb2312"%><%@ page import="java.util.*"%><%    String q=request.getParameter("q");   q = q == null? "没有值" : q; %><HTML><HEAD><TITLE>新闻列表显示</TITLE><META http-equiv=Content-Type content="text/html; charset=gb2312"><META http-equiv=pragma content=no-cache><body>你提交了:<%=q%><br><form action="tcnchar.jsp" method="post">  输入中文:<input type="text" name="q"><input type="submit" value="确定">  <br>  <a href="tcnchar.jsp?q=中国">通过get方式提交</a>  </form></BODY></HTML>

测试结果如果你输入文本框或者点超链都会显示:你提交了”中国”,说明成功!!!!!



作者 Re:tomcat5.0.28又来玩不支持中文了 [Re:gegew]
scottlai



元老


发贴: 451
积分: 366
于 2004-09-16 12:52 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
他的問題看起來的不是request.get...()
是page的內容變成亂碼了..



作者 Re:tomcat5.0.28又来玩不支持中文了 [Re:alin_ass]
alin_ass





发贴: 183
积分: 0
于 2004-09-20 15:31 user profilesend a private message to usersend email to alin_asssearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
to gegew :
1.但是get方式的解决办法如果要修改 server.xml 提交给用户怎么办?
2.设置URIEncoding=”GBK”,但是我要实现i18n,不一定是gbk,我在filter里根据
request.encoding做redirect,暂时没发现乱码问题。

to scottlai :
能否把 每张jsp中的最上2行
 <%@ page session="false" pageEncoding="GBK" %>
<%@ include file="include.jspf" %>


移到 某个统一的地方?比如web.xml或者mede-inf/context.xml?

3ks a lot !!!!



叫我包子
作者 Re:tomcat5.0.28又来玩不支持中文了 [Re:alin_ass]
alin_ass





发贴: 183
积分: 0
于 2004-09-20 15:41 user profilesend a private message to usersend email to alin_asssearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
再问下,楼上有谁把数据库里的资料全用unicode存的?这样日后维护会碰到什么问题?


叫我包子

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923