package com.tmsp.cms.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;

public class CharacterEncoding implements Filter {

	/**
	 * Constructor of the object.
	 */
	public CharacterEncoding() {
		super();
	}

	/**
	 * Initialization of the servlet. 
* * @throws ServletException * if an error occurs */ public void init() throws ServletException { // Put your code here } public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { // TODO Auto-generated method stub arg0.setCharacterEncoding("utf-8"); arg2.doFilter(arg0, arg1); } public void init(FilterConfig arg0) throws ServletException { // TODO Auto-generated method stub } public void destroy() { // TODO Auto-generated method stub } }

web.xml 配置


		CharacterEncoding
		com.tmsp.cms.filter.CharacterEncoding
	
	
		CharacterEncoding
		/*
	

By 三疯

发表评论

电子邮件地址不会被公开。 必填项已用*标注