Javadream

          A long way and a dream.

          WebWork 2.2 學習筆記(二)

          Posted on 2006-05-04 01:02 oxl 閱讀(380) 評論(0)  編輯  收藏 所屬分類: Java Web技術
          逐個講解WebWork中的一些配置文件的基本用法:
          ----------------------------------------------------------------------------
          web.xml
          <filter>
          ????
          <filter-name>webwork</filter-name>
          ????
          <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
          </filter>
          <filter-mapping>
          ????
          <filter-name>webwork</filter-name>
          ????
          <url-pattern>/*</url-pattern>
          </filter-mapping>
          <listener>
          ????
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          </listener>

          這里使用了一個Filter來對所有的url進行過濾,而只有在webwork.properties中的設定的webwork.action.extension作為擴展名才會被解悉為一個action.
          而定義了一個監聽器主要是用Spring的監聽Web容器里的變化,這里主要是用于Spring作為WebWork的IoC.如果想讓Spring有多個context配置文件,那就可加入下面的代碼:
          <context-param>
          ????
          <param-name>contextConfigLocation</param-name>
          ????
          <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
          </context-param>
          *param-value是用逗號隔開的配置文件列表,記住是用相對于Web應用的路徑.

          這里如果想定義一個WebWork tag,那么就可加入以下的代碼:
          <taglib>
          ????
          <taglib-uri>webwork</taglib-uri>
          ????
          <taglib-location>/WEB-INF/lib/webworkxx.jar</taglib-location>
          </taglib>
          這樣,在視圖jsp文件中引用WebWork tag時,只須要把uri="webwork"就行了,而不用寫成這樣uri="/webwork".

          --------------------------------------------------------------------------------
          在說xwork.xml之前,我們先了解webwork-default.xml文件,這個文件是由webwork.jar文件里有的,存放在classpath中,所以我們不用創建這個文件,因為每次運行webwork應用時,webwork都會自動去classpath查找這個文件.這個文件預先設置好了一些默認的參數,比如result type, interceptors等,可以說是我們xwork.xml中的默認值,同時也為我們的xwork.xml提供好了很多工具,比如params攔截器就是最典型的一個.

          在編寫xwork.xml時,我們一般都要導入這個webwork-default.xml文件,代碼如下:
          <include?file="webwork-default.xml"/>

          具體的xwork.xml配置,由以后的學習中給出...(呵....我也還不清楚,沒有實踐過呢..)
          xwork.xml文件必須放在/WEB-INF/classes/中.

          --------------------------------------------------------------------------------

          下面說一下webwork.properties文件,這個文件是配置webwork行為特性的文件,他可以改變webwork的擴展名,以及編碼等.這個文件的詳細說明可以參考官方的文檔:
          ###?Webwork?default?properties
          ###(can?be?overridden?by?a?webwork.properties?file?in?the?root?of?the?classpath)
          ###

          ###?Specifies?the?Configuration?used?to?configure?webwork
          ###?one?could?extend?com.opensymphony.webwork.config.Configuration
          ###?to?build?one's?customize?way?of?getting?the?configurations?parameters?into?webwork
          #?webwork.configuration=com.opensymphony.webwork.config.DefaultConfiguration

          ###?This?can?be?used?to?set?your?default?locale?and?encoding?scheme
          #?webwork.locale=en_US

          webwork.i18n.encoding=UTF-8

          ###?if?specified,?the?default?object?factory?can?be?overridden?here
          ###?Note:?short-hand?notation?is?supported?in?some?cases,?such?as?"spring"
          ###???????Alternatively,?you?can?provide?a?com.opensymphony.xwork.ObjectFactory?subclass?name?here
          #?webwork.objectFactory?=?spring

          ###?specifies?the?autoWiring?logic?when?using?the?SpringObjectFactory.
          ###?valid?values?are:?name,?type,?auto,?and?constructor?(name?is?the?default)

          webwork.objectFactory.spring.autoWire?=?name

          ###?Parser?to?handle?HTTP?POST?requests,?encoded?using?the?MIME-type?multipart/form-data
          #?webwork.multipart.parser=cos
          #?webwork.multipart.parser=pell

          webwork.multipart.parser=jakarta
          #?uses?javax.servlet.context.tempdir?by?default
          webwork.multipart.saveDir=
          webwork
          .multipart.maxSize=2097152

          ###?Load?custom?property?files?(does?not?override?webwork.properties!)
          #?webwork.custom.properties=application,com/webwork/extension/custom

          ###?How?request?URLs?are?mapped?to?and?from?actions

          webwork.mapper.class=com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper

          ###?Used?by?the?DefaultActionMapper
          webwork.action.extension=action

          ###?use?alternative?syntax?that?requires?%{}?in?most?places
          ###?to?evaluate?expressions?for?String?attributes?for?tags

          webwork.tag.altSyntax=true

          ###?when?set?to?true,?WebWork?will?act?much?more?friendly?for?developers.?This
          ###?includes:
          ###?-?webwork.i18n.reload?=?true
          ###?-?webwork.configuration.xml.reload?=?true
          ###?-?raising?various?debug?or?ignorable?problems?to?errors
          ###???For?example:?normally?a?request?to?foo.action?someUnknownField=true?should
          ###????????????????be?ignored?(given?that?any?value?can?come?from?the?web?and?it
          ###????????????????should?not?be?trusted).?However,?during?development,?it?may?be
          ###????????????????useful?to?know?when?these?errors?are?happening?and?be?told?of
          ###????????????????them?right?away.

          webwork.devMode?=?false

          ###?when?set?to?true,?resource?bundles?will?be?reloaded?on?_every_?request.
          ###?this?is?good?during?development,?but?should?never?be?used?in?production

          webwork.i18n.reload=false

          ###?Standard?UI?theme
          ###?Change?this?to?reflect?which?path?should?be?used?for?JSP?control?tag?templates?by?default

          webwork.ui.theme=xhtml
          webwork
          .ui.templateDir=template
          #sets?the?default?template?type.?Either?ftl,?vm,?or?jsp
          webwork.ui.templateSuffix=ftl

          ###?Configuration?reloading
          ###?This?will?cause?the?configuration?to?reload?xwork.xml?when?it?is?changed

          webwork.configuration.xml.reload=false

          ###?Location?of?velocity.properties?file.??defaults?to?velocity.properties
          #?webwork.velocity.configfile?=?velocity.properties

          ###?Comma?separated?list?of?VelocityContext?classnames?to?chain?to?the?WebWorkVelocityContext
          #?webwork.velocity.contexts?=

          ###?used?to?build?URLs,?such?as?the?UrlTag

          webwork.url.http.port?=?80
          webwork
          .url.https.port?=?443

          ###?Load?custom?default?resource?bundles
          #?webwork.custom.i18n.resources=testmessages,testmessages2

          ###?workaround?for?some?app?servers?that?don't?handle?HttpServletRequest.getParameterMap()
          ###?often?used?for?WebLogic,?Orion,?and?OC4J

          webwork.dispatcher.parametersWorkaround?=?false

          ###?configure?the?Freemarker?Manager?class?to?be?used
          ###?Allows?user?to?plug-in?customised?Freemarker?Manager?if?necessary
          ###?MUST?extends?off?com.opensymphony.webwork.views.freemarker.FreemarkerManager
          #webwork.freemarker.manager.classname=com.opensymphony.webwork.views.freemarker.FreemarkerManager

          ###?See?the?WebWorkBeanWrapper?javadocs?for?more?information

          webwork.freemarker.wrapper.altMap=true

          好,大至上已經清楚了這些文件的大至用途,下一步,弄清xwork的配置.























          主站蜘蛛池模板: 澄迈县| 西充县| 临澧县| 巴彦淖尔市| 巨野县| 延津县| 龙川县| 卓资县| 东兴市| 米泉市| 茌平县| 三明市| 汝南县| 商水县| 遂昌县| 汪清县| 镇沅| 大邑县| 泰宁县| 和田县| 浦县| 灵石县| 岑溪市| 铜山县| 贵阳市| 旌德县| 板桥市| 长沙县| 麦盖提县| 眉山市| 沙田区| 连云港市| 蒙自县| 丰宁| 阿鲁科尔沁旗| 临汾市| 永和县| 北京市| 胶南市| 正镶白旗| 资溪县|