多个dwr.xml配置

<!-- 配置dwr2,可配置一个servlet多个dwr.xml,或者多个servlet多个dwr.xml -->

<servlet>

         <servlet-name>dwr-invoker</servlet-name>

         <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>

         <init-param>

                   <param-name>config</param-name>

                   <param-value>WEB-INF/dwr.xml</param-value>

         </init-param>

         <init-param>

                   <param-name>config-2</param-name>

                   <param-value>WEB-INF/dwr-2.xml</param-value>

         </init-param>

         <init-param>

                   <param-name>debug</param-name>

                   <param-value>true</param-value>

         </init-param>

</servlet>

<servlet-mapping>

         <servlet-name>dwr-invoker</servlet-name>

         <url-pattern>/dwr/*</url-pattern>

</servlet-mapping>

<!-- 配置第二个DwrServletxml配置独立 -->

<servlet>

         <servlet-name>dwr-invoker2</servlet-name>

         <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>

         <init-param>

                   <param-name>config</param-name>

                   <param-value>WEB-INF/dwr2.xml</param-value>

         </init-param>

</servlet>

<servlet-mapping>

         <servlet-name>dwr-invoker2</servlet-name>

         <url-pattern>/dwr2/*</url-pattern>

</servlet-mapping>

 dwr.xml

<dwr>

         <allow>

                   <create creator="new" javascript="UserService" scope="session">

                            <param name="class" value="dwrDemo.UserService" />

                            <!-- 仅公开以下方法 -->

                            <include method="say" />

                            <include method="getUser" />

                   </create>

                   <convert converter="bean" match="dwrDemo.UserVO">

                            <!-- 仅公开以下属性 -->

                            <param name="include" value="username" />

                   </convert>

         </allow>

</dwr>

 dwr-2.xml,与dwr.xml相同作用域

<dwr>

         <allow>

                   <!-- 重复定义,后者无效 -->

                   <create creator="new" javascript="UserService" scope="session">

                            <param name="class" value="dwrDemo.UserService" />

                            <include method="getUserList" />

                   </create>

                   <!-- 重复定义,后者生效 -->

                   <convert converter="bean" match="dwrDemo.UserVO">

                   </convert>

         </allow>

</dwr>

 dwr2.xml,与dwr.xmldwr-2.xml不在一个作用域,js中的访问路径为dwr2/interface/UserService2.js

<dwr>

         <allow>

                   <create creator="new" javascript="UserService2" scope="session">

                            <param name="class" value="dwrDemo.UserService" />

                            <include method="say" />

                            <include method="getUser" />

                            <include method="getUserList" />

                   </create>

                   <convert converter="bean" match="dwrDemo.UserVO">

                            <param name="include" value="username" />

                   </convert>

         </allow>

</dwr>

 

 

 

 

【】

你可能感兴趣的:(xml)