風人園

          弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
          隨筆 - 99, 文章 - 181, 評論 - 56, 引用 - 0
          數據加載中……

          Struts 2.0 起步

          參考 http://www.aygfsteel.com/max/category/16130.html

          1、添加struts2的jar包,struts2-core-2.x.x.jar, struts2-api-2.x.x.jar (struts2-all-2.x.x.jar即可,其他的struts2的插件包已經包含在里面)。
             如添加其他的插件包,可能會出現文件重復,具體可以看異常信息。
             或者不要加all包,而使用插件包,可以減小包的大小。
          2、修改web.xml

           1 <? xml version="1.0" encoding="UTF-8" ?>
           2 < web-app  version ="2.4"  
           3  xmlns ="http://java.sun.com/xml/ns/j2ee"  
           4  xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"  
           5  xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee 
           6  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
           7   < display-name > Struts2 Hello World! </ display-name >   
           8
           9     < filter >
          10          < filter-name > Struts2 </ filter-name >
          11          < filter-class >
          12             org.apache.struts2.dispatcher.FilterDispatcher
          13          </ filter-class >
          14      </ filter >
          15      < filter-mapping >   
          16          < filter-name > Struts2 </ filter-name >   
          17          < url-pattern > /* </ url-pattern >   
          18      </ filter-mapping >   
          19 </ web-app >
          20


          3、在classpath下添加struts.properties文件,內容如下
          struts.devMode = true
          struts.enable.DynamicMethodInvocation = false

          4、在classpath下添加struts.xml,這個是對應struts1.x里面的struts-config.xml

           1 <! DOCTYPE struts PUBLIC
           2         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
           3         "http://struts.apache.org/dtds/struts-2.0.dtd" >
           4 < struts >
           5      < package  name ="example"  extends ="struts-default" >
           6          < action  name ="hello"  class ="com.ivo.struts2.HelloWorld"  method ="aliasAction" >
           7              < result > /hello.jsp </ result >
           8          </ action >
           9          < action  name ="Login"  class ="com.ivo.struts2.Login" >
          10        < result > /hello.jsp </ result >
          11    </ action >
          12    < action  name ="LoginX"  class ="com.ivo.struts2.LoginX" >
          13        < result > /hello.jsp </ result >
          14    </ action >
          15      </ package >
          16 </ struts >


          注意,struts2的兩個相關文件需要放在classpath下

          posted on 2006-12-29 10:09 風人園 閱讀(534) 評論(0)  編輯  收藏 所屬分類: Struts2

          主站蜘蛛池模板: 资中县| 临桂县| 尼玛县| 高尔夫| 平潭县| 肃北| 大庆市| 岑溪市| 德州市| 肇庆市| 八宿县| 措美县| 平江县| 焦作市| 安阳县| 怀宁县| 建瓯市| 塔河县| 房山区| 关岭| 石门县| 清流县| 通渭县| 淳化县| 启东市| 麦盖提县| 菏泽市| 乌鲁木齐县| 遵义县| 江门市| 青龙| 贵溪市| 长垣县| 恩平市| 洛川县| 沙坪坝区| 桓仁| 元江| 巴青县| 黄平县| 象州县|