EncodingFilter.java
资源名称:exams.rar [点击查看]
上传用户:nbxinmin
上传日期:2021-10-09
资源大小:46k
文件大小:1k
源码类别:
Internet/IE编程
开发平台:
Java
- package com.xdf.exams.filter;
- 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.http.HttpServletRequest;
- public class EncodingFilter implements Filter{
- public void destroy() {
- }
- public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
- HttpServletRequest request = (HttpServletRequest)req;
- //设置请求中文
- request.setCharacterEncoding("GBK");
- //继续处理
- chain.doFilter(req,resp);
- }
- public void init(FilterConfig config) throws ServletException {
- }
- }