struts2框架 基础搭建
2017-01-07 09:46
232 查看
一、 当然是导入所需Jar包到lib下:
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
commons-fileupload-1.3.2.jar
commons-io-2.2.jar
commons-lang3-3.2.jar
freemarker-2.3.22.jar
javassist-3.11.0.GA.jar
log4j-api-2.3.jar
log4j-core-2.3.jar
ognl-3.0.19.jar
struts2-core-2.3.30.jar
xwork-core-2.3.30.jar
二、编写web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>01_struts2_hello</display-name>
<filter>
<filter-name>struts2</filter-name>
<!-- 配置struts2核心控控制器,
复制struts2-core-2.3.30.jar的包下面的
org.apache.struts2.dispatcher.ng.filter下面的
StrutsPrepareAndExecuteFilter 包名跟类名,再去掉后面的.class -->
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
三、在src下新建一个struts2.xml文件:
上代码:
<?xml version="1.0" encoding="UTF-8"?>
<!-- 找到struts2-core-2.3.30.jar展开找到struts-default.xml打开,复制35-39行头文件过来,用“</struts>”结下尾-->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
</struts>
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
commons-fileupload-1.3.2.jar
commons-io-2.2.jar
commons-lang3-3.2.jar
freemarker-2.3.22.jar
javassist-3.11.0.GA.jar
log4j-api-2.3.jar
log4j-core-2.3.jar
ognl-3.0.19.jar
struts2-core-2.3.30.jar
xwork-core-2.3.30.jar
二、编写web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>01_struts2_hello</display-name>
<filter>
<filter-name>struts2</filter-name>
<!-- 配置struts2核心控控制器,
复制struts2-core-2.3.30.jar的包下面的
org.apache.struts2.dispatcher.ng.filter下面的
StrutsPrepareAndExecuteFilter 包名跟类名,再去掉后面的.class -->
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
三、在src下新建一个struts2.xml文件:
上代码:
<?xml version="1.0" encoding="UTF-8"?>
<!-- 找到struts2-core-2.3.30.jar展开找到struts-default.xml打开,复制35-39行头文件过来,用“</struts>”结下尾-->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
</struts>
相关文章推荐
- struts2框架基础web环境搭建
- Struts2框架 -- 基础知识+搭建
- struts2环境搭建---【小白系列】0基础到熟练应用struts2框架(一)
- Spring.NET学习笔记2——环境搭建(基础篇)(转)
- 搭建电信之“云”需从基础入手 业务拓展紧跟市场需求
- 搭建EXTJS和STRUTS2框架(ext和struts2简单实例)
- 搭建 comet im 基础链接框架
- 2009年免费暑期JAVA基础巩固训练营热身——环境搭建视频
- 转:win2000/2003 Discuz生存环境搭建及基础优化
- struts2框架搭建第三天
- struts2框架搭建第一天
- win2000/2003 Discuz生存环境搭建及基础优化 攻略
- 搭建简单web项目: spring3.0基础配置(1)
- MeeGo进阶基础篇6– Meego下搭建QT环境
- Spring.NET教程(二)——环境搭建(基础篇) (转)
- 搭建EXTJS和STRUTS2框架(ext和struts2简单实例)
- 使用 PHP 搭建自己的视频点播网站,第 1 部分:基础工作
- Windows下使用VIM,搭建Mainframe开发环境(三)---基础配置
- 搭建基础Junit环境
- MeeGo进阶基础篇6– MeeGo下搭建Qt环境