風人園

          弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
          隨筆 - 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 風人園 閱讀(541) 評論(0)  編輯  收藏 所屬分類: Struts2

          主站蜘蛛池模板: 保靖县| 平远县| 拉萨市| 甘南县| 上杭县| 乌恰县| 汪清县| 金沙县| 海原县| 象山县| 龙口市| 博白县| 深圳市| 平南县| 西华县| 望都县| 天祝| 和田市| 昌都县| 通山县| 高唐县| 福建省| 保定市| 弥渡县| 云和县| 疏勒县| 社旗县| 绍兴县| 黑水县| 旌德县| 镇远县| 大城县| 沂源县| 安宁市| 时尚| 九台市| 郎溪县| 玉山县| 枝江市| 荣昌县| 恩施市|