工作空间,工程,我都改成gbk了,可页面仍然是乱码,发现每个页面的编码都是iso-8859-1,修改成gbk后就行了。
可是有那么多的jsp页面,难道要一个一个的修改,有解决办法吗???
可是有那么多的jsp页面,难道要一个一个的修改,有解决办法吗???
解决方案 »
- jsp在线考试系统页面无刷新随时保存答案功能实现
- ####@@@@@###关于点击出现另几张图片的问题,请教大侠
- 自定义标签如何使用useBean的属性?
- 网页发布的问题
- 急求!!! 棘手的servelt问题
- 今天上jsp第一课在家,按照书上配置拉个文件,文件是在自定义的目录中的,可以访问有异常可以帮我看看吗?谢谢
- 客户想做一个像51job 和cjol.com哪样的网站,各位帮帮忙,报个价呀。
- 手机号查询
- 50分求救!同一个JSP页面中为什么不能定义两个数据库结果集??
- 大家用的tomcat什么版本?奇怪的问题。
- 请问如何很好的设计一个二级页面?(JSP+MSSQL+TOMAT的)
- jsp怎么样实现类似.net上自定义控件的功能
2、写过滤器,设置request.setCharacterEncoding("UTF-8")。
3、javascript脚本里用encodeURI(str)。
4、适当的时候,在jsp里用java.net.URLDecoder.decode(request.getParameter("str"),"UTF-8")。
5、最容易忽略的是使用"":value=" <%=paraFiles%>",一定要有引号。
6、new String(content.getBytes("ISO-8859-1"), "GBK");
如果感觉一个一个改jsp太慢了,
那可以....两个两个的修改\( ̄▽ ̄)/
右键你的工程名-->Properties-->Info-->Text file encoding-->other-->选择gbk。
<filter>
<filter-name>SetCharacterEncoding</filter-name>
<filter-class>tools.CharsetFilter</filter-class>
<init-param>
<param-name>Encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
import javax.servlet.*;public class CharsetFilter implements Filter {
protected String encoding = null;
protected FilterConfig filterConfig = null;
protected String getEncoding() {
return (this.encoding);
}
public void destroy() {
this.encoding = null;
this.filterConfig = null;
} public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException,
ServletException { if (request.getCharacterEncoding() == null) {
String encoding = getEncoding(); //得到指定的编码名字
if (encoding != null)
request.setCharacterEncoding(encoding); //设置request的编码
} chain.doFilter(request, response); //有机会执行下一个filter
} public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("Encoding");
}
}