jsp乱码问题

来源:百度知道 编辑:UC知道 时间:2024/05/08 20:36:10
tomcat jakarta-tomcat-5.5.9.exe
jdk j2sdk-1_4_2_08.exe
曾经使用过C:\Tomcat\conf\web.xml中修改一下内容
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html;charset=gb2312</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html;charset=gb2312</mime-type>
</mime-mapping>

<%@ page contentType="text/html; charset=gb2312" %>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">但是不可以。如果加上<%@ page contentType="text/html; charset=gb2312" %>这句页面浏览都不可以。会出现
org.apache.jasper.JasperException: /index.jsp(2,0) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html;charset=gb2312, new: text/html; charset=gb2312)
org.apache.jasper.compiler.D

用jdk j2sdk-1_4_2_09+tomcat5.0.28

将gb2312改为GBK试试

所有的都默认设置,在页面开头加
<%@ page contentType="text/html; charset=gb2312" %>应该就可以的,处理表单时加request.setCharacterEncoding("gb2312");

如果有什么问题,那不是页面的事了,检查你的tomcat
哎,刚才没看出来,tomcat5.5.9好象需要配的是jdk5吧,换个tomcat5.0.28,再看看,我觉得5.5并不比5.0好用

只保留<%@ page contentType="text/html; charset=gb2312" %>这句,把这句
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">删除,它会认为这两个不是一个字符集,以前我遇到过这种情况!

错误写的很清楚:多个不同的ContentType值是非法的。

把<meta http-equiv="Content-Type" content="text/html; charset=gb2312">删掉试试。

总之知道出错原因,应该很好改的。

我做的jsp都是有<%@ page contentType="text/html; charset=gb2312" %>又有
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
没有问题,如果要去掉的话应该是你的web.xml里的内容
如果页面没有<meta http-equiv="Content-Type" content=&qu