论坛首页 Java企业应用论坛

dwr spring结合

浏览 2435 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (1)
作者 正文
   发表时间:2008-04-01   最后修改:2009-01-30

applicationContext.xml修改头部信息

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"> 

<dwr:configuration></dwr:configuration>

 

 web.xml文件中加入以下信息 

<servlet> <servlet-name>dwr-invoker</servlet-name> <servlet-class> org.directwebremoting.spring.DwrSpringServlet </servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>pollAndCometEnabled</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></servlet>

 bean的配置

<bean id="userService" class="services.impl.UserServiceImpl"> <property name="userDao"> <ref bean="userDao"> </property> <dwr:remote javascript="userManager"></dwr:remote> </bean>  

JSP页面引用:

<script type='text/javascript' src='/xtt/dwr/interface/userManager.js'></script>
 	 	<script type='text/javascript' src='/xtt/dwr/engine.js'></script>

调用时直接引用其方法名即可,如:userManager.hello();

此配置不需要dwr.xml

 

论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics