<%@
page
language="java"
import="java.util.*"
pageEncoding="GBK"%>
能行的
我一般都这样做的
如果是tomcat修改server.xml增加 URIEncoding="GBK"
<Connector port="8080" ...... URIEncoding="GBK"/>
可解决post提交的乱码.
get方法提交乱码可web.xml中增加filter
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>
org.....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>
类SetCharacterEncodingFilter可在tomcat自带的sample中找到.
将html中<html></html>标签中的内容替换jsp页面中<html></html>内容即可。但注意jsp页面中的第一行:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> 改为:
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)