update
This commit is contained in:
parent
71f2333be3
commit
a85bb8d57f
|
@ -0,0 +1,46 @@
|
|||
package com.zheng.demo.interceptor;
|
||||
|
||||
import com.zheng.common.util.PropertiesFileUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 拦截器
|
||||
* Created by shuzheng on 2017/3/24.
|
||||
*/
|
||||
public class DemoInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
private static Logger _log = LoggerFactory.getLogger(DemoInterceptor.class);
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
// 过滤ajax
|
||||
if (null != request.getHeader("X-Requested-With") && request.getHeader("X-Requested-With").equalsIgnoreCase("XMLHttpRequest")) {
|
||||
return true;
|
||||
}
|
||||
String appName = PropertiesFileUtil.getInstance().get("app.name");
|
||||
//request.setAttribute("");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
super.postHandle(request, response, handler, modelAndView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
super.afterCompletion(request, response, handler, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
super.afterConcurrentHandlingStarted(request, response, handler);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
app.name=${app.name}
|
||||
env=${profile.env}
|
||||
zheng-ui.version=${zheng-ui.version}
|
||||
zheng-ui.path=${zheng-ui.path}
|
|
@ -1,3 +1,4 @@
|
|||
app.name=zheng-demo
|
||||
profile.env=dev
|
||||
zheng-ui.version=1.0.0
|
||||
zheng-ui.path=http://ui.zhangshuzheng.cn:1000/
|
|
@ -1,3 +1,4 @@
|
|||
app.name=zheng-demo
|
||||
profile.env=pre
|
||||
zheng-ui.version=1.0.0
|
||||
zheng-ui.path=http://ui.zhangshuzheng.cn:1000/
|
|
@ -1,3 +1,4 @@
|
|||
app.name=zheng-demo
|
||||
profile.env=prod
|
||||
zheng-ui.version=1.0.0
|
||||
zheng-ui.path=http://ui.zhangshuzheng.cn:1000/
|
|
@ -1,3 +1,4 @@
|
|||
app.name=zheng-demo
|
||||
profile.env=test
|
||||
zheng-ui.version=1.0.0
|
||||
zheng-ui.path=http://ui.zhangshuzheng.cn:1000/
|
|
@ -2,8 +2,18 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
<!-- 拦截器 -->
|
||||
<mvc:interceptors>
|
||||
<!-- 获取登录信息 -->
|
||||
<mvc:interceptor>
|
||||
<mvc:mapping path="/**"/>
|
||||
<bean class="com.zheng.demo.interceptor.DemoInterceptor"></bean>
|
||||
</mvc:interceptor>
|
||||
</mvc:interceptors>
|
||||
|
||||
<context:property-placeholder location="classpath:config.properties"/>
|
||||
|
||||
|
|
Loading…
Reference in New Issue