当前位置: 代码迷 >> Eclipse >> Eclipse中中文有关问题解决不了?
  详细解决方案

Eclipse中中文有关问题解决不了?

热度:71   发布时间:2016-04-23 18:39:17.0
Eclipse中中文问题解决不了????
我在eclipse中进行了一下设置:
    windows--> preperences--> Greneral--> Cotent   Types--> Text--> Jsp--> Default   encoding   设置为GBK
  Project--> properties--> Info--> Text   file   encoding设置为GBK
然后struts项目的jsp文件中,加入了:
<%@page   pageEncoding= "GB2312 "%>
<%@page   contentType= "text/html;   charset=gb2312 "   language= "java "%>
<%request.setCharacterEncoding( "GB2312 ");%>
怎么我在登陆页面输入的中文在下页显示的仍然是??????
希望大家帮忙,谢谢!

------解决方案--------------------
request只是解决了接收到的信息进行编码,传出去的也要编码的.
response.setContentType( "text/html;charset=gbk ");这句也要的
------解决方案--------------------
做个过滤器就都解决了

------解决方案--------------------
同意楼上的意见
把tomcat的这个文件加到你的web工程里再改一下web.xml就可以了
webapps\examples\WEB-INF\classes\filters\SetCharacterEncodingFilter.java

在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>


------解决方案--------------------
baiydn(蓝色雪狐)是正确的
  相关解决方案