합쭈기 programming

url filter setting 본문

Java/Spring

url filter setting

innocent_k 2015. 6. 17. 16:02
final String[] PASS_URL = {{로그인url}}; 
	
	
@Override
protected void doFilterInternal(HttpServletRequest paramHttpServletRequest,
	HttpServletResponse paramHttpServletResponse,
	FilterChain paramFilterChain) throws ServletException, IOException {
		
	String url = paramHttpServletRequest.getRequestURI();								
	String[] splitUrl = url.split("\\.");
		
	if (!isPass(url) && splitUrl.length < 2)
	{
	if (paramHttpServletRequest.getSession().getAttribute({세션이름}) 
== null)
		{
			paramHttpServletResponse.sendRedirect({로그인url});
			return;
		}
				
	}	
		
	paramFilterChain.doFilter(paramHttpServletRequest,           paramHttpServletResponse);
		
}	
	
protected boolean isPass(String url) 
{
	for (String passUrl : PASS_URL)
	{
		if (url.indexOf(passUrl) > -1)
			return true;
	}
	return false;
}

'Java > Spring' 카테고리의 다른 글

mutipart resolver 안될때  (0) 2015.06.19
maven 빌드 시 junit test 제외  (0) 2015.06.18
log4j 로그 출력이 안될때  (0) 2015.06.10
log4j path 설정  (0) 2015.06.07
jUnit DB 테스트  (0) 2015.06.05