未登錄
下面向大家詳細介紹spring mvc Session攔截器的使用
代碼如下
[html]
package com
import com
import java
import java
import javax
import javax
import org
import org
/**
*
* @author yh
*/
public class SessionInterceptor implements HandlerInterceptor {
private Logger logger = Logger
@Override
public boolean preHandle(HttpServletRequest hsr
User user=(User) hsr
if(user==null){
logger
hsr
return false;
}
return true;
}
@Override
public void postHandle(HttpServletRequest hsr
}
@Override
public void afterCompletion(HttpServletRequest hsr
}
}
package com
import com
import java
import java
import javax
import javax
import org
import org
/**
*
* @author yh
*/
public class SessionInterceptor implements HandlerInterceptor {
private Logger logger = Logger
@Override
public boolean preHandle(HttpServletRequest hsr
User user=(User) hsr
if(user==null){
logger
hsr
return false;
}
return true;
}
@Override
public void postHandle(HttpServletRequest hsr
}
@Override
public void afterCompletion(HttpServletRequest hsr
}
}
僅這些還不夠
[html]
<!
<mvc:interceptors >
<mvc:interceptor>
<mvc:mapping path=
<mvc:mapping path=
<mvc:mapping path=
<mvc:mapping path=
<mvc:mapping path=
<bean class=
</mvc:interceptor>
</mvc:interceptors>
<!
<mvc:interceptors >
<mvc:interceptor>
<mvc:mapping path=
<mvc:mapping path=
<mvc:mapping path=
<mvc:mapping path=
<mvc:mapping path=
<bean class=
</mvc:interceptor>
</mvc:interceptors>如有訪客不明白的可以給我留言
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28855.html