日期:2014-05-18  浏览次数:20746 次

JSP乱码老问题?两个文件包含之后的中文乱码问题,附代码.高手帮忙,谢谢
文件za.JSP代码如下:
<%@   include   file= "zz.jsp "   %>
<%   out.print( "中文 ");   %>

文件zz.jsp
<%@   page   contentType= "text/html;charset=GBK "   %>
<%   out.print( "我是zz ");   %>

浏览za.jsp,出来的结果是

我是zz   ????

这样的,也就是zz.jsp里的中文不是乱码,而za.jsp里的中文就是乱码,高手帮忙,谢谢

------解决方案--------------------
<%@ page contentType= "text/html;charset=GBK " %>
//////////////////改成
<%@ page contentType= "text/html;charset=utf-8 " %>

------解决方案--------------------
楼上正解
------解决方案--------------------
在za.JSP的head部分加入:
<%@ page contentType= "text/html;charset=GBK " %>
------解决方案--------------------
可以使用过滤器,
<filter>
<filter-name> Set Character Encoding </filter-name>
<filter-class> com.medicine.filter.SetCharacterEncodingFilter </filter-class>
<init-param>
<param-name> encoding </param-name>
<param-value> GBK </param-value>
</init-param>
</filter>
------解决方案--------------------
在za.jsp顶端 <%@ page language= "java " contentType= "text/html; charset=gb2312 "
pageEncoding= "gb2312 "%>
------解决方案--------------------
1。在za.jsp顶端 <%@ page language= "java " contentType= "text/html; charset=gb2312 "
%>
2。在server.xml里的 connector 里面加如下:
<Connector port= "8080 "
maxThreads= "150 " minSpareThreads= "25 " maxSpareThreads= "75 "
enableLookups= "false " redirectPort= "8443 " acceptCount= "100 "
debug= "0 " connectionTimeout= "20000 "
disableUploadTimeout= "true " URIEncoding= 'GBK ' />



------解决方案--------------------
up