转载请注明:http://www.csdn.net/develop/article/17/17204.shtm
使用filter来改变request的编码 【程序编程相关:(转载)修改Windows SMB相关服】
作者:ggyy1977@hotmail.com 【推荐阅读:(转载)获取Windows 系统的内核变】
知道当没有指定request的编码的时候,从客户端得到的数据是iso-8859-1编码的(request.getparameter()得到传递的参数值); 【扩展信息:解决IIS启动时出现0x8ffe2740】
在前面的文章里面,我们讨论了在tomcat下的jsp与servlet的字符编码问题!
但是我们怎么来改变request的编码呢?
方法有很多种!
比如:在getrequestdispatcher("/jsp/jsptoserv/hello.jsp").forward(request, response);之前修改
request的编码,那么在jsp/jsptoserv/hello.jsp中得到的参数值就是制定的编码的字符.
本文我们使用filter来修改request的编码!
1)首先编写filter类:
package myfilter;
import java.io.ioexception; import javax.servlet.*;public class changecharsetfilter implements filter {
protected string encoding = null;/////要制定的编码,在web.xml中配置 protected filterconfig filterconfig = null;public void destroy() {
... 下一页