初探STRUTS

一.編程工具:MyEclipse。java

 

二.jar代碼包(共八個jar包):web

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.jarapache

 

三.搭建struts環境:編程

1.新建web project項目:app

 

2.修改web.xml文件:jsp

具體配置文件以下:工具

 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文件,可查看下面配置文件:url

 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,看是否有提示報錯信息:spa

 

成功加載struts,如今能夠開始學習struts了.....

相關文章
相關標籤/搜索