public class AuthorizationPermissionInterceptor implements MethodBeforeAdvice{
public void before(Method methodName, Object[] objs, Object obj) throws Throwable {
}
}
拦截器的配置如下:
<bean id="aroundAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref local="permissionInterceptor"/>
</property>
<property name="pattern">
<value>.*Service.*(..)</value>
</property>
</bean>
做权限方面的验证,想使用拦截器来拦截,使用的是方法的拦截。
现在的问题是我如何在拦截的before中获得session?
有这方面的朋友,请帮忙,谢谢!
------解决方案--------------------------------------------------------
给个思路:
http://zg770423.blog.163.com/blog/static/13826688820112275259181/
希望可以帮助到你
------解决方案--------------------------------------------------------
百度。。。
------解决方案--------------------------------------------------------
写一个类存放session
- Java code
public class SessionStore { private static ThreadLocal mySession = new ThreadLocal(); public static HttpSession getWebSession() { HttpSession session = (HttpSession) mySession.get(); return session; } public static void setWebSession(HttpSession session) { mySession.set(session); }}
------解决方案--------------------------------------------------------
用到struts2么?HttpSession session = ServletActionContext.getRequest().getSession();