struts jsp中文问题——过滤器

1:设置Filter编码转换

package eline.deck.util;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class SetCharacterEncodingFilter implements Filter {
public void init(FilterConfig config) throws ServletException {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
request.setCharacterEncoding("GB2312");
chain.doFilter(request,response);
}
public void destroy() {
}
}
我的Filter类 包名eline.deck.util
然后在web.xml设置

SetCharacterEncodingFilter
eline.deck.util.SetCharacterEncodingFilter


SetCharacterEncodingFilter
/*

当然上边这一段是放在webapp标签里边的..
2;以上的步骤只会在你提交跳转页面是才会工作的,,至于普通的JSP的页面
页面显示中文,你只需设置你的contentType=GB2312在
在Jsp的html代码中,声明GB2312:

你可能感兴趣的:(Framework,jsp,struts,import,filter,webapp,class)