初探STRUTS

一.编程工具:MyEclipse。

 

二.jar代码包(共八个jar包):

commons-fileupload-1.3.1.jar,commons-io-2.2.jar,commons-lang3-3.2.jar,freemarker-2.3.19.jar,javassist-3.11.0.GA.jar,ognl-3.0.6.jar,struts2-core-2.3.20.jar,xwork-core-2.3.20.jar

 

三.搭建struts环境:

1.新建web project项目:

 

2.修改web.xml文件:

具体配置文件如下:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app version="2.5" 
 3     xmlns="http://java.sun.com/xml/ns/javaee" 
 4     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 5     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
 6     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 7   <filter>
 8      <filter-name>struts2</filter-name>
 9      <filter-class>
10          org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
11      </filter-class>
12   </filter>
13   <filter-mapping>
14      <filter-name>struts2</filter-name>
15      <url-pattern>/*</url-pattern>
16   </filter-mapping>
17   <welcome-file-list>
18     <welcome-file>index.jsp</welcome-file>
19   </welcome-file-list>
20 </web-app>

 

3.新建struts.xml文件(文件可新建在src目录下):

 

4.修改struts文件,可查看下面配置文件:

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE struts PUBLIC
 3     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
 4     "http://struts.apache.org/dtds/struts-2.0.dtd">
 5 <struts>
 6     <!--  Action package name 必须唯一 -->
 7     <package name="/default" extends="struts-default" namespace="/">
 8         <!-- action -->
 9     
10     </package>
11 </struts>

 

5.开启Tommat,看是否有提示报错信息:

 

成功加载struts,现在可以开始学习struts了.....

 

posted @ 2014-12-15 15:36  sky of chuanqingchen  阅读(207)  评论(0编辑  收藏  举报