250x250
Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- git
- Exception
- Open Source
- JavaScript
- Source
- error
- jpa
- Thymeleaf
- SpringBoot
- Python
- MySQL
- JDBC
- ubuntu
- 문서
- Eclipse
- 오픈소스
- PostgreSQL
- spring
- myBatis
- AJAX
- Docker
- STS
- oracle
- Tomcat
- 설정
- Core Java
- Spring Boot
- MSSQL
- IntelliJ
- maven
Archives
- Today
- Total
헤르메스 LIFE
[Source] EncodingFilter.java 본문
728x90
package com.sample.utils;
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 encoding = null;
/**
* 필터 설정 관리자
*/
protected FilterConfig filterConfig = null;
/*
* (non-Javadoc)
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter("encoding");
}
/*
* (non-Javadoc)
* @see javax.servlet.Filter#destroy()
*/
public void destroy() {
this.encoding = null;
this.filterConfig = null;
}
/*
* (non-Javadoc)
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (request.getCharacterEncoding() == null) {
if (encoding != null) {
request.setCharacterEncoding(encoding);
}
}
chain.doFilter(request, response);
}
/**
* @return
*/
public FilterConfig getFilterConfig() {
return filterConfig;
}
/**
* @param cfg
*/
public void setFilterConfig(FilterConfig cfg) {
filterConfig = cfg;
}
}
728x90
'Core Java' 카테고리의 다른 글
| [OpenSource] 토비 Spring 3 - ConfigurableDispatcherServlet (0) | 2012.06.22 |
|---|---|
| [Source] Common Java Cookbook (0) | 2012.06.20 |
| [Source] A test of the Thin driver for an application (0) | 2011.11.07 |
| 에러, 버그, 예외 (Error, Bug, Exception) (0) | 2011.05.03 |
| Underscore 와 field 네이밍 컨벤션 (0) | 2011.05.03 |