ssh登录拦截器配置
2015-07-22 22:55
344 查看
struts.xml的配置
java文件配置
<interceptors> <interceptor name="LoginInterceptor" class="com.jeizas.Interceptor.LoginInterceptor"></interceptor> <interceptor-stack name="LoginInterceptorStack"> <interceptor-ref name="LoginInterceptor" /> <interceptor-ref name="defaultStack" /> </interceptor-stack> </interceptors> <interceptor-ref name="LoginInterceptorStack"><interceptor-ref>
java文件配置
import java.util.Map; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; public class LoginInterceptor extends AbstractInterceptor { /** * */ private static final long serialVersionUID = 1L; @Override public String intercept(ActionInvocation arg0) throws Exception { // TODO Auto-generated method stub String actionName = arg0.getInvocationContext().getName();//获得当前要调用的action if(actionName == "LoginUserAction"){//登录所用的action放行 return arg0.invoke(); } Map<String,Object> session=ActionContext.getContext().getSession(); Object user=session.get("loginUser");//从session中获得登录用户 if(user != null){ return arg0.invoke(); }else{ return Action.LOGIN; } } }
相关文章推荐
- C#高级编程四十八天----列表
- C++内存池实现
- Chrome 扩展机制
- 同性恋科技,我才刚上路?
- UIImageView 个人学习总结
- oc008---xcode的使用注意事项(逐步补充当中)
- Cocos2d-x制作跳棋结束总结
- ubuntu使用问题
- gdb调试
- MySQL忘记root用户密码的解决办法
- Learn OpenGLES: HelloWorld
- 为什么要有向上转型
- HD 1269迷宫城堡
- 宽字符的应用
- 五个 Linux 下用户空间的调试工具
- Linux系统进程间隔定时器Itimer
- CF 558B Amr and The Large Array
- 关于 WEB/HTTP 调试利器 Fiddler 的一些技巧分享
- GridLayout的基本用法
- SA,SD和SE的差别