1. servlet-context.xml 설정

<interceptors>
	<interceptor>
		<mapping path="/**/*" />
			<exclude-mapping path="/main/*" />
			<exclude-mapping path="/login/*" />
		<beans:bean class="com.jeyun.controllers.HelloInterceptor"></beans:bean>
	</interceptor>
</interceptors>

2. interceptor.java 설정

package com.text.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class Interceptor implements HandlerInterceptor {

	public boolean preHandle(HttpServletRequest req, HttpServletResponse res, Object handler) {
		return true;
	}

	public void postHandle(HttpServletRequest req, HttpServletResponse res, Object handler, ModelAndView mv) {
		//
	}
  
	public void afterCompletion(HttpServletRequest req, HttpServletResponse res, Object handler, Exception ex) {
		//
	}
  
}

 

블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,