package filters;
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;
import javax.servlet.UnavailableException;
public class SetCharacterEncodingFilter implements Filter {
protected String encoding = null;
protected FilterConfig filterConfig = null;
protected boolean ignore = true;
public void destroy() {
this.encoding = null;
this.filterConfig = null;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (ignore || (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
if (encoding != null)
request.setCharacterEncoding(encoding);
}
chain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
String value = filterConfig.getInitParameter("ignore");
if (value == null)
this.ignore = true;
else if (value.equalsIgnoreCase("true"))
this.ignore = true;
else if (value.equalsIgnoreCase("yes"))
this.ignore = true;
else
this.ignore = false;
}
protected String selectEncoding(ServletRequest request) {
return (this.encoding);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Struts上传,已经处理好乱码问题
共18个文件
class:3个
java:3个
properties:2个
需积分: 0 1 下载量 25 浏览量
2008-11-04
10:01:46
上传
评论
收藏 10KB RAR 举报
温馨提示
Struts上传,已经处理好乱码问题Struts上传,已经处理好乱码问题
资源详情
资源评论
资源推荐
收起资源包目录
StrutsUpload.rar (18个子文件)
StrutsUpload
.mystrutsdata 262B
src
com
yourcompany
struts
ApplicationResources.properties 95B
form
LoadForm.java 1KB
action
LoadAction.java 1KB
filters
SetCharacterEncodingFilter.java 1KB
.project 1KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 1KB
.struts-config.mex 48B
classes
com
yourcompany
struts
ApplicationResources.properties 95B
form
LoadForm.class 1KB
action
LoadAction.class 2KB
filters
SetCharacterEncodingFilter.class 2KB
struts-config.xml 796B
lib
up.jsp 579B
index.jsp 834B
.mymetadata 309B
.classpath 599B
.myeclipse
共 18 条
- 1
爱编程的皮皮虾
- 粉丝: 36
- 资源: 110
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0