隨筆 - 45, 文章 - 6, 評論 - 4, 引用 - 0
          數據加載中……

          struts2應用程序結構

           程序目錄結構

          project

          -JSP

          -WEB-INF

            - src

            - classes

              - struts.xml

              - struts.properties

            - lib

            - build.xml

            - applicationContext.xml

            - web.xml

           

          -lib目錄下放置struts2的開發包,包含struts2所依懶的包,也可以是程序開發后打包的結果

          -src自開發程序(原碼目錄)

           

           

          ---------------------web.xml-----------------------

          <?xml version="1.0" encoding="UTF-8"?>
          <web-app version="2.4" xmlns="
          http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

              <display-name>Struts Blank</display-name>

              <filter>
                  <filter-name>struts2</filter-name>
                  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
              </filter>

              <filter-mapping>
                  <filter-name>struts2</filter-name>
                  <url-pattern>/*</url-pattern>
              </filter-mapping>
             

              <context-param>
                 <param-name>contextConfigLocation</param-name>
                 <param-value>/WEB-INF/applicationContext.xml</param-value>
               </context-param>


              <listener>
                  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
              </listener>  

          </web-app>

          1配置了struts2攔截機

          2加入spring載入偵聽

           

          ------------------struts.xml------------------------

          <?xml version="1.0" encoding="UTF-8" ?>

          <!DOCTYPE struts PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
              "
          http://struts.apache.org/dtds/struts-2.0.dtd">
          <struts>

              <package name="default" extends="struts-default">

                  <action name="Login" class="LoginAction">
                      <result name="success">/welcome.jsp</result>
                      <result name="error">/error.jsp</result>
                  </action>

              </package>

           

          配置了一個包,定義了一個action和兩個結果

           

           

          ---------------------------struts.properties-------------

          struts.i18n.encoding=GBK

           

          定義了默認的編碼規則

          posted on 2009-05-01 09:29 liyang 閱讀(762) 評論(0)  編輯  收藏 所屬分類: apache

          主站蜘蛛池模板: 锡林浩特市| 怀柔区| 浦县| 酒泉市| 墨脱县| 清丰县| 忻州市| 建瓯市| 六盘水市| 白城市| 泰安市| 宜州市| 蒲城县| 八宿县| 彰化市| 平陆县| 新乐市| 岗巴县| 荔浦县| 镇平县| 吉水县| 辉南县| 旬邑县| 湘潭市| 江西省| 彭阳县| 泸溪县| 垣曲县| 黎平县| 多伦县| 黔西县| 竹北市| 应城市| 梁河县| 英超| 广宗县| 无为县| 新郑市| 莒南县| 宁乡县| 屯昌县|