|
Posted on 2006-05-04 01:02 oxl 阅读(374) 评论(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的配置.
|