创建struts2项目的步骤和拦截器配置
来源:互联网 发布:access录入数据 编辑:程序博客网 时间:2024/06/15 21:48
1,创建web project
2,右键加载struts2的框架
3,写页面,写对应的action
4,写配置文件。加上package,action
5,编写action里面对应的后台action和实体类
6,将后台处理成功之后的页面加在result标签里面
7,写一个result页面。
8,将工程加载到tomcat里面
9,启动tomcat,访问。
如何加载拦截器
1,写一个拦截器的包
2,写一个拦截器类。
有三种方式: *第一种:实现interceptor接口
*第二种:继承abstractInterceptor类
*第三种:继承MethodFilterInterceptor类
3,在配置文件里面定义拦截器
<!-- 定义一个拦截器 -->
<interceptors>
<interceptor name="userInterceptor" class="com.hope.web.interceptor.UserInterceptor"></interceptor>
<!-- 定义一个拦截器栈 -->
<interceptor-stack name="userStack">
<interceptor-ref name="userInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
4,在配置文件里面使用拦截器
<action name="login" class="com.hope.web.action.LoginAction" method="login">
<result name="success">result.jsp</result>
<!-- 如何使用一个拦截器 -->
<interceptor-ref name="userInterceptor"></interceptor-ref>
<!-- 使用拦截器栈 -->
<interceptor-ref name="userStack"></interceptor-ref>
</action>
2,右键加载struts2的框架
3,写页面,写对应的action
4,写配置文件。加上package,action
5,编写action里面对应的后台action和实体类
6,将后台处理成功之后的页面加在result标签里面
7,写一个result页面。
8,将工程加载到tomcat里面
9,启动tomcat,访问。
如何加载拦截器
1,写一个拦截器的包
2,写一个拦截器类。
有三种方式: *第一种:实现interceptor接口
*第二种:继承abstractInterceptor类
*第三种:继承MethodFilterInterceptor类
3,在配置文件里面定义拦截器
<!-- 定义一个拦截器 -->
<interceptors>
<interceptor name="userInterceptor" class="com.hope.web.interceptor.UserInterceptor"></interceptor>
<!-- 定义一个拦截器栈 -->
<interceptor-stack name="userStack">
<interceptor-ref name="userInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
4,在配置文件里面使用拦截器
<action name="login" class="com.hope.web.action.LoginAction" method="login">
<result name="success">result.jsp</result>
<!-- 如何使用一个拦截器 -->
<interceptor-ref name="userInterceptor"></interceptor-ref>
<!-- 使用拦截器栈 -->
<interceptor-ref name="userStack"></interceptor-ref>
</action>
0 0
- 创建struts2项目的步骤和拦截器配置
- struts2的自定义拦截器和配置
- Struts2拦截器的配置和使用
- Struts2配置拦截器和拦截链
- Struts2配置拦截器和拦截链
- struts2拦截器的配置
- struts2 拦截器的配置
- 配置struts2的拦截器
- Struts2拦截器的配置
- springmvc和struts2拦截器的简单使用以及配置
- Struts2 自定义拦截器配置和使用
- Struts2 拦截器原理和配置
- struts2中拦截器的全局拦截和自定义拦截
- struts2的拦截器(1):拦截器的配置和使用
- Struts2拦截器配置
- struts2 拦截器配置
- Struts2配置拦截器
- 配置struts2拦截器
- Linux系统调用API容错机制
- 二叉树的非递归遍历
- elasticsearch的安装和启动(亲测可行)
- UDP主要丢包原因及具体问题分析
- 双网卡同时上内外网方法
- 创建struts2项目的步骤和拦截器配置
- idea导入java项目
- Python中冒泡排序:
- MySQL前缀索引和索引选择性
- Linux-理解ARP、网关、路由
- mybatis教程
- 向消息队列发送一个消息(后进先出LIFO),OSQPostFront()
- “==”和“equals”的用法
- QT调用命令行程序