struts拦截器配置流程
来源:互联网 发布:宁泽涛傅园慧cp乐乎 编辑:程序博客网 时间:2024/05/22 11:55
1.新建拦截器实现MethodFilterInterceptor接口
public class PrivailegeInterceptor extends MethodFilterInterceptor {
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
//1.获得session
Map<String, Object> session = ActionContext.getContext().getSession();
Object session1 = session.get("user");
if(session1!=null){
//2.有就放行
invocation.invoke();
}
//3.没有就gg
return "tolgoin";
}
}
2.在struts配置文件中配置
<package name="Action" namespace="/" extends="struts-default">
<interceptors>
<!-- 注册拦截器 -->
<interceptor name="PrivailegeInteceptor" class="cn/txj/web/Interceptor/PrivailegeInterceptor.java"></interceptor>
<!-- 注册拦截器栈(其中excludeMethods代表不执行的方法名称)-->
<interceptor-stack name="systemInteceptor">
<interceptor-ref name="PrivailegeInteceptor">
<param name="excludeMethods">regist,login</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<!-- 指定拦截器 -->
<default-interceptor-ref name="systemInteceptor"></default-interceptor-ref>
- struts拦截器配置流程
- struts拦截器配置
- Struts 拦截器配置
- struts拦截器执行流程
- Struts拦截器代码配置
- 使用struts配置拦截器
- struts学习:拦截器配置
- struts拦截器的配置
- struts 拦截器入门&执行流程
- 【Struts】拦截器的执行流程
- struts自定义拦截器及其执行流程
- struts拦截器配置,以及全局的拦截器配置
- struts通配符和拦截器配置
- 模版:struts.xml配置拦截器
- Struts为所有包配置拦截器
- STRUTS系列之 拦截器配置
- struts拦截器配置和使用
- Struts 2读书笔记-----拦截器之拦截器的配置
- 高级网络服务
- spring过滤器和拦截器的区别与联系
- spring Transactional注解
- python Windows下安装第三方包
- WinSockAPI的使用
- struts拦截器配置流程
- 学习Pandas(七)
- 【安全牛学习笔记】手动漏洞挖掘(四)
- Failure to transfer org.codehaus.plexus:plexus-interpolation:jar:1.15
- SOCKET 编程实例
- Spring Cloud zuul自定义统一异常处理实现
- VC6.0以及DEV-C++的替换功能
- 加密锁破解|破解WibuKey CodeMeter AxProtector CmActLicense CmDongle CodeMeter
- linux下helloworld无法运行的问题