He'llWorld_Struts2
【步骤】
1.创建web项目
2.导入相关jar包

3.配置核心过滤器
web app libraris ---> struts-core ---> org.apache.struts2.dispatcher.ng.filter ---> StrutsPrepareAndExecuteFilter(Struts2的核心过滤器)
<!-- 过滤器 -->
<filter>
<filter-name>StrutsPrepareAndExecuteFilter</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>StrutsPrepareAndExecuteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
4.添加Struts2的配置文件
src ---> struts.xml --->复制struts-default.xml内容(web app libraris >> struts-core >> META-INF >> struts-default.xml) --->粘贴到struts2 配置文件 >> 去掉注释
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> </struts>
5.创建Action类
public class HelloAction {
/**
* 请求处理方法
* 相当于Servlet中的Service
* @return
*/
public String execute(){
System.out.println("execute is do......");
return "success";
}
}
6. 配置Action类
修改struts.xml中的内容。
<struts>
<!--
name :包名
extends :表示继承于struts-default
-->
<package name="hello" extends="struts-default">
<!--
name :Action的名称,相当于servlet的映射名
class :Action的完整名称(包名 + 类名)
-->
<action name="hello" class="cn.hl.action.HelloAction">
<!--
控制跳转结果
-->
<result>index.jsp</result>
</action>
</package> </struts>
7.布署项目
8.访问action

He'llWorld_Struts2的更多相关文章
随机推荐
- CH#56C(LCA+dfs序)
题目传送门 性质是:把节点dfs序以后,异象石按这个序号排序,然后相邻两两求树上距离,这些距离的和除以二就是最小斯坦纳树. 插入删除的具体操作是根据我们上述性质,用一个set维护dfn,比如插入x,则 ...
- Codeforces Round #410 (Div. 2) A
Description Mike has a string s consisting of only lowercase English letters. He wants to change exa ...
- bzoj2154||洛谷P1829 Crash的数字表格&&JZPTAB && bzoj3309 DZY Loves Math
bzoj2154||洛谷P1829 https://www.lydsy.com/JudgeOnline/problem.php?id=2154 https://www.luogu.org/proble ...
- Chemistry in Berland CodeForces - 846E
题目 题意: 有n种化学物质,第i种物质现有bi千克,需要ai千克.有n-1种,编号为2-n的转换方式,每种都为(x,k),第i行是编号为i+1的转换方式,编号为i的转换方式(xi,ki)表示ki千克 ...
- JavaScript入门2
5.document对象:Document对象是window对象的一个对象属性,代表浏览器窗口中装载的整个HTML文档.文档中的每个HTML元素对应着JavaScript对象. 因为document代 ...
- 02.第二章_C++ Primer学习笔记_变量和基本类型
2.1 基本内置类型 2.1.1 算术类型 算术类型包括两类:整型和浮点型 2.2 变量 2.3 复合类型 2.4 const限定符 2.5 处理类型 2.6 自定义数据结构
- 可能是最漂亮的Spring事务管理详解 专题
微信阅读地址链接:可能是最漂亮的Spring事务管理详解 事务概念回顾 什么是事务? 事务是逻辑上的一组操作,要么都执行,要么都不执行. 事物的特性(ACID): 原子性: 事务是最小的执行单位,不允 ...
- 初学.net增删改查
分页显示 DAL: public List GetListByPager(int PageIndex, int PageSize, out int RowCount) { string sql = & ...
- 03.Java多线程并发库API使用2
1.多个线程之间共享数据的方式探讨 1.如果每个线程执行的代码相同,可以使用同一个Runnable对象,这个Runnable对象中有那个共享数据,例如,买票系统就可以这么做. 2.如果每个线程执行的代 ...
- pandas中loc-iloc-ix的使用
转自:https://www.jianshu.com/p/d6a9845a0a34 Pandas中loc,iloc,ix的使用 使用 iloc 从DataFrame中筛选数据 iloc 是基于“位置” ...