Struttd2 开发步骤及流程

使用Struts 2 开发程序的基本步骤

 

 

01.Struts 2及其优势

 

Struts 2是一个MVC框架,以WebWork框架的设计思想为核心,吸收了Struts 1的部分优点

 

 

 

Struts 2拥有更加广阔的前景,自身功能强大,还对其他框架下开发的程序提供很好的兼容性

 

加载Struts2 类库

 

核心类库

1junit

2 xwork  Struts2的基本包

javaee-api api使用包

 

4.struts2-core struts2的核心 (心脏)没他不行

 

 

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>


<!--获取ServletAPI-->
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->

<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts.xwork/xwork-core -->
<!-- https://mvnrepository.com/artifact/com.opensymphony/xwork-core -->
<dependency>
<groupId>com.opensymphony</groupId>
<artifactId>xwork-core</artifactId>
<version>2.1.6</version>
</dependency>

 


 

配置web.xml文件

用户过来的一个请求会先进入这里

 

<!--Struts2 核心过滤器-->
<filter>
<filter-name>Struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<!-- 拦截所有的action -->
<filter-mapping>
<filter-name>Struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

 

开发视图层页面

 

 

开发控制层Action

配置struts.xml文件

部署、运行项目

 

 

dispatcher
posted @ 2017-10-24 15:24  liuzhe01  阅读(145)  评论(0编辑  收藏  举报