第一步:下载框架包
文件简介
apps:直接可以放在服务器运行的案例
docs:文档
lib:库
src:struts2的源码包
第二步:为struts项目增加必须的jar
commons-fileupload-1.2.2.jar 处理文件上传的
commons-io-2.0.1.jar fileupload依赖这个
commons-lang3-3.1.jar
commons-logging-1.1.1.jar 日志处理
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar 之前存在与ognl.jar中,新版本分离出来了
ognl-3.0.6.jar struts表达式语言
struts2-core-2.3.14.2.jar struts2内核
xwork-core-2.3.14.2.jar xwork内核
第三步:web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
第四步:struts.xml这个文件在src下面创建
<?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">