1. Struts2的安装配置
1.1下载
进入apache的官方网:http://struts.apache.org/download.cgi#struts2316下载struts2的GA完整版,Struts 2.3.16.3是Struts 2.3.X系列最稳定的版本。下载完后,解压到本地磁盘,该文件夹包含如下文件结构:
apps:该文件夹下包含了struts 2 的示例应用。
docs:struts2的相关文档,包含struts2的快速入门、struts2的帮助文档及API文档等内容。
lib:该文件夹下包含了struts2框架的核心类库,以及struts2的第三方插件类库。
src:该文件下包含了struts2框架的全部源代码。
1.2添加Struts2依赖
这里主需要在pom.xml中添加一个struts-core的依赖即可:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.carson.demo</groupId>
<artifactId>struts2</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>struts2 Maven Webapp</name>
<url>http://maven.apache.org</url>
<!-- 属性配置 -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<!-- st