DWR 配置与参数
DWR 配置与参数
WEB.XML
|
Creator |
Param |
User |
new |
class |
类的全名称(包括包路径) |
scripted |
language |
BSF框架支持的脚本语言名称(BSF为apache项目) |
script |
返回远程对象的脚本,脚本可以指定一些属性,多数情况下一般只设置param节点配置.属性很少设置. |
|
spring |
Location* |
任何以location开头的参数,每个参数都是指定一个spring的配置文件,在参数没有设置的情况下DWR会去读取spring的全局的配置文件. |
beanName |
从配置文件中读取的bean的名称 |
new:
<allow>
<create creator="new" javascript="Blah">
<param name="class" value="java.util.Date"/>
</create>
...
</allow>
static: 看官网文档 http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/creators/index.html#none
none:看官网文档 http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/creators/index.html#none
scripted:
<allow>
...
<create creator="script" javascript="EmailValidator">
<param name="class" value="org.apache.commons.validator.EmailValidator"/>
<param name="language" value="beanshell"/>
<param name="script">
import org.apache.commons.validator.EmailValidator;
return EmailValidator.getInstance();
</param>
</create>
...
</allow>
Parameter | DWRVersion | Description |
---|---|---|
language | 1.0 | The language that we are scripting in. This string is passed to BSF. For example 'beanshell'. (required) |
class | 1.0 | The type of object that is created. This is required for security reasons. |
script | 1.0 | The script to execute which will return a Java Object to remote. (required unless scriptPath is used) |
scriptPath | 1.1 | The path to a script stored in a file. (required unless script is used) |
reloadable | 1.1 | Should the ScriptedCreator check for changes to scripts loaded using scriptPath? (optional,defaults to true) |
spring:
<allow>
...
<create creator="spring" javascript="Fred">
<param name="beanName" value="Shiela"/>
</create>
...
</allow>
使用location*参数
如果你要在dwr.xml中指定使用哪些bean,你可以使用location*参数。你可以指定任意多个文件,只要参数以location开始并且唯一即可。例如:location-1,location-2。这些location被用做Spring的ClassPathXmlApplicationContext的参数:
<allow>
<createcreator="spring"javascript="Fred">
<paramname="beanName"value="Shiela"/>
<paramname="location"value="beans.xml"/>
</create>
</allow>
直接设置BeanFactory
SpringCreator有一个静态方法setOverrideBeanFactory(BeanFactory)用来通过编程的方式直接设置BeanFactory。
JSF:看官网文档 http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/creators/index.html#none
Struts:看官网文档 http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/creators/index.html#none
pageflow:看官网文档 http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/creators/index.html#none
Converters:
http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/converters/index.html(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!