[b]DWR整合Sturts配置[/b]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr20.dtd">
<!--
[color=blue] creator置为"struts";
param元素中的
name值为formBean,
value值为struts-config.xml配置文件中的form-bean元素的name值[/color]
-->
<dwr>
<allow>
<create javascript="strutsDwr" creator="struts">
<param name="formBean" value="dwrForm"></param>
</create>
<convert converter="bean" match="com.dwr.struts.form.DwrForm"/>
</allow>
</dwr>
[b]DWR整合Spring配置[/b]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr20.dtd">
<!-- [color=blue]DWR整合Spring配置
creator属性的值可以是new,struts,spring、jsf、scripted、pageflow、none
因为此处是整合spring来做的,所以设置成"spring",
javascript="usercard" 表示实例转换成javascript语言后以usercard命名,
param元素的name属性值可以是class,beanName等,
此处用beanName,value得值是定义在applicationContext.xml中某个bean的id值。 [/color]
-->
<dwr>
<allow>
<create javascript="usercard" creator="spring">
<param name="beanName" value="usercard"></param>
</create>
<convert match="com.aptech.enterprise.entity.Usercard"
converter="bean">
</convert>
</allow>
</dwr>
[b]以下这段代码为web.xml配置内容,所有Dwr配轩文件放置在WEB-INF目录下。[/b]
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!--
[color=blue]DWR与Spring整合
初始化WebApplicationContext [/color]
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- [color=blue]配置DWR拦截器(一个Servlet对应多个DWR)[/color] -->
<servlet>
<servlet-name>dwr</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<!-- [color=blue]构造new的DWR[/color] -->
<init-param>
<param-name>config-dwr</param-name>
<param-value>WEB-INF/dwr.xml</param-value>
</init-param>
<!-- [color=blue]构造Spring的DWR[/color] -->
<init-param>
<param-name>config-usercard</param-name>
<param-value>WEB-INF/usercardDwr.xml</param-value>
</init-param>
<!-- [color=blue]构造Struts的DWR[/color] -->
<init-param>
<param-name>config-strutsDwr</param-name>
<param-value>WEB-INF/StrutsDwr.xml</param-value>
</init-param>
<!-- [color=blue]配置DWR调试参数[/color] -->
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
</servlet>
<!-- [color=blue]结束DWR配置[/color] -->
<!-- [color=blue]Struts拦截器配置 [/color]-->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<!--[color=blue]过滤器映射[/color]-->
<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr20.dtd">
<!--
[color=blue] creator置为"struts";
param元素中的
name值为formBean,
value值为struts-config.xml配置文件中的form-bean元素的name值[/color]
-->
<dwr>
<allow>
<create javascript="strutsDwr" creator="struts">
<param name="formBean" value="dwrForm"></param>
</create>
<convert converter="bean" match="com.dwr.struts.form.DwrForm"/>
</allow>
</dwr>
[b]DWR整合Spring配置[/b]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr20.dtd">
<!-- [color=blue]DWR整合Spring配置
creator属性的值可以是new,struts,spring、jsf、scripted、pageflow、none
因为此处是整合spring来做的,所以设置成"spring",
javascript="usercard" 表示实例转换成javascript语言后以usercard命名,
param元素的name属性值可以是class,beanName等,
此处用beanName,value得值是定义在applicationContext.xml中某个bean的id值。 [/color]
-->
<dwr>
<allow>
<create javascript="usercard" creator="spring">
<param name="beanName" value="usercard"></param>
</create>
<convert match="com.aptech.enterprise.entity.Usercard"
converter="bean">
</convert>
</allow>
</dwr>
[b]以下这段代码为web.xml配置内容,所有Dwr配轩文件放置在WEB-INF目录下。[/b]
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!--
[color=blue]DWR与Spring整合
初始化WebApplicationContext [/color]
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- [color=blue]配置DWR拦截器(一个Servlet对应多个DWR)[/color] -->
<servlet>
<servlet-name>dwr</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<!-- [color=blue]构造new的DWR[/color] -->
<init-param>
<param-name>config-dwr</param-name>
<param-value>WEB-INF/dwr.xml</param-value>
</init-param>
<!-- [color=blue]构造Spring的DWR[/color] -->
<init-param>
<param-name>config-usercard</param-name>
<param-value>WEB-INF/usercardDwr.xml</param-value>
</init-param>
<!-- [color=blue]构造Struts的DWR[/color] -->
<init-param>
<param-name>config-strutsDwr</param-name>
<param-value>WEB-INF/StrutsDwr.xml</param-value>
</init-param>
<!-- [color=blue]配置DWR调试参数[/color] -->
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
</servlet>
<!-- [color=blue]结束DWR配置[/color] -->
<!-- [color=blue]Struts拦截器配置 [/color]-->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<!--[color=blue]过滤器映射[/color]-->
<servlet-mapping>
<servlet-name>dwr</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>