EncodingFilter 구현
package com.eBrother.wepa.web.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 EncodingFilter implements Filter {
private String encofing = null;
protected FilterConfig filterConfig = null;
public void destroy() {
this.encoding = null;
this.filterConfig = null;
}
/**
* ServletRequest
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,ServletException{
if(request.getCharacterEncoding() == null){
if(encoding != null){
request.setCharacterEncoding(encoding);
}
}
request.setCharacterEncoding(encoding);
chain.doFilter(request, response);
}
/**
* web.xml
*/
public void init(FilterConfig filterConfig) throws ServletException{
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
}
public FilterConfig getFilterConfig() {
return filterConfig;
}
public void setFilterConfig(FilterConfig cfg){
filterConfig = cfg;
}
}
'JAVA' 카테고리의 다른 글
[JAVA] 에러정의 web.xml (0) | 2017.11.07 |
---|---|
[JAVA] error (0) | 2017.11.06 |
[JAVA]Download outOfMemory (0) | 2017.11.03 |
[JAVA]Dispatche :: request.getRequestDispatcher("/prg/board_excel.jsp"); (0) | 2017.11.03 |
[JAVA]dbconnection 끊어지는 현상 (0) | 2017.11.03 |