SpringMVC 登陆拦截器实现登陆控制
程序员文章站
2022-07-15 08:18:06
...
12345678910111213141516171819202122232425262728293031/**
* 登陆拦截器.
*
* @author leizhimin 2014/6/26 16:08
*/
public
class
LoginInterceptor
extends
HandlerInterceptorAdapter {
private
static
final
String[] IGNORE_URI = {
"/login.jsp"
,
"/Login/"
,
"backui/"
,
"frontui/"
};
@Override
public
boolean
preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws
Exception {
boolean
flag =
false
;
String url = request.getRequestURL().toString();
System.out.println(
">>>: "
+ url);
for
(String s : IGNORE_URI) {
if
(url.contains(s)) {
flag =
true
;
break
;
}
}
if
(!flag) {
T_supplier_user user = LoginController.getLoginUser(request);
if
(user !=
null
) flag =
true
;
}
return
flag;
}
@Override
public
void
postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
throws
Exception {
super
.postHandle(request, response, handler, modelAndView);
}
}
1
2
3
4
5
6
|
< mvc:interceptors >
< mvc:interceptor >
< mvc:mapping path = "/**" />
< bean id = "loginInterceptor" class = "net.xiucheren.web.interceptor.LoginInterceptor" />
</ mvc:interceptor >
</ mvc:interceptors >
|
上一篇: Java的取模取余运算
下一篇: jquery遍历数组