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

把web.xml中的配置信息输出到浏览器页面,为什么中文信息为乱码?
关于这个jsp文件在web.xml中的配置信息为:
<servlet>
                <servlet-name> test </servlet-name>
<jsp-file>
/config.jsp
        </jsp-file>
<init-param>
<param-name>
email
</param-name>
<param-value>
青岛卓软科技有限公司:www.libinsoft.com
</param-value>
</init-param>
        </servlet>
        <servlet-mapping>
<servlet-name> test </servlet-name>
<url-pattern> /config.jsp </url-pattern>
</servlet-mapping>
我在config.jsp文件中通过cofig配置对象输出对于email信息的配置
<%@   page   contentType= "text/html;charset=gb2312 "%>
<html>
<body>
<center>
<br>
青岛卓软科技有限公司客户服务中心:
<%=   new   String(config.getInitParameter( "email ").getBytes( "ISO8859-1 "), "GB2312 ")%>
</center>
</body>
</html>
启动tomcat但是在浏览器中显示这样的信息:配置文件中的中文信息显示的为乱码:
青岛卓软科技有限公司客户服务中心:   ???????????www.libinsoft.com  
怎样解决这个问题:
请高手赐教!!!我会不胜感激!!!

------解决方案--------------------
根据web.xml的编码相应转换。
关注并学习中。。。
------解决方案--------------------
注意到: getBytes( "ISO8859-1 ")写错了,少了一个 "- ",应该是getBytes( "ISO-8859-1 ").