在springmvc.xml檔案裡添加:
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.xxx.xxx.interceptor.XxxInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
"/**" 代表攔截所有請求。