拦截器---java
来源:互联网 发布:java swing的网格布局 编辑:程序博客网 时间:2024/06/04 19:07
拦截器—java
代码
public class SpringAuthInterceptor extends HandlerInterceptorAdapter { private static final Log log = LogFactory.getLog(SpringAuthInterceptor.class); private static final int BUSSINESS_TYPE = 2; private static final List<String> BUSSINESS_EXCLUDE_URL = new ArrayList<String>(); @Autowired private SystemManagementService systemManagementService; static { BUSSINESS_EXCLUDE_URL.addAll(ListUtil.toList(new String[] { "/bigdata/issueCommand/index.do", "/bigdata/issueCommand/mfIndex.do", "/bigdata/issueCommand/list.do", "/bigdata/denyOrLift/index.do", "/bigdata/basicData/index.do", "bigdata/cdnsubnet/create.do", "bigdata/cdnsubnet/index.do" })); } @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException, ServletException { HttpSession session = request.getSession(); String applicationPath = request.getContextPath(); String requestPath = request.getRequestURI().substring(applicationPath.length()); User user = (User) session.getAttribute("user"); if (null == user) { response.sendRedirect(applicationPath + "/login.do"); return false; } else { // 如果是业务员,判断访问URL的权限 if (user.getType() == BUSSINESS_TYPE && BUSSINESS_EXCLUDE_URL.contains(requestPath)) { response.sendRedirect(applicationPath + "/index.do"); return false; } } log.info(requestPath); try {// 存日志失败,也要继续,查询操作不存日志,简单规则TODO String lowerpath = requestPath.toLowerCase(); if (!lowerpath.contains("index.do") && !lowerpath.contains("list.do") && !lowerpath.contains("query.do")) { systemManagementService.saveLog(user.getUsername(), IPUtil.findRequestIP(request), requestPath); } } catch (RuntimeException e) { log.error(e.getMessage(), e); } return true; }}
0 0
- Java简单拦截器
- java实现拦截器
- java 拦截器
- java 拦截器、过滤器
- java拦截器原理
- JAVA Web 拦截器
- java拦截器
- java 拦截器、过滤器
- java拦截器模型
- Java简单拦截器
- Java 注解 拦截器
- java拦截器实例
- Java 过滤器 拦截器
- Java拦截器
- java之拦截器
- 拦截器---java
- java实现拦截器
- java登录拦截器
- Filter过滤器
- Java创建型设计模式-建造者(3)
- 异常: -source 1.6 中不支持 diamond 运算符 (请使用 -source 7 或更高版本以启用 diamond 运算符)
- Google Playe 服务搭建
- UCOS-II内存管理
- 拦截器---java
- 0-1背包问题
- java的FutureTask的public 方法的解析
- Java和Android的Thread源码分析
- Google浏览器 chrome老是拦截flash
- 模板_prim最小生成树算法
- lftp使用
- 本地文件跨域访问
- 开关为什么是接在火线上