论坛首页 入门技术论坛

Spring2 与 DWR2 的整合问题

浏览 6463 次
该帖已经被评为新手帖
作者 正文
   发表时间:2007-11-01  
DWR
我想整合Spring2 与 DWR2但是总是提示:UserService is not defined !
不清楚是什么地方出现的问题,在网上搜索了一些资料都是这样配置的,希望大家帮我看一下是什么地方出现问题。
谢谢大家了,下面是相关配置文件。


ApplicationContext.xml :
xml 代码
 
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">  
  5.   
  6.     <bean id="userService"   
  7. class="org.Spring2AndDWR2.test.service.impl.UserServiceImpl"></bean>  
  8. </beans>  

dwr.xml
xml 代码
 
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://www.getahead.ltd.uk/dwr/dwr20.dtd">  
  3. <dwr>  
  4.     <allow>  
  5.         <create creator="spring" javascript="UserService">  
  6.             <param name="beanName" value="userService"/>  
  7.             <param name="location" value="applicationContext.xml"/>  
  8.         </create>  
  9.     </allow>  
  10. </dwr>  

web.xml
xml 代码
 
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   
  5.     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
  6.   
  7.     <context-param>  
  8.         <param-name>contextConfigLocation</param-name>  
  9.         <param-value>  
  10.             /WEB-INF/classes/applicationContext.xml  
  11.         </param-value>  
  12.     </context-param>  
  13.   
  14.     <listener>  
  15.         <listener-class>  
  16.             org.springframework.web.context.ContextLoaderListener  
  17.         </listener-class>  
  18.     </listener>  
  19.   
  20.     <servlet>  
  21.         <servlet-name>Dispatcher</servlet-name>  
  22.         <servlet-class>  
  23.             org.springframework.web.servlet.DispatcherServlet  
  24.         </servlet-class>  
  25.         <init-param>  
  26.             <param-name>contextConfigLocation</param-name>  
  27.             <param-value>/WEB-INF/classes/Spring2AndDWR2-servlet.xml</param-value>  
  28.         </init-param>  
  29.     </servlet>  
  30.     <servlet-mapping>  
  31.         <servlet-name>Dispatcher</servlet-name>  
  32.         <url-pattern>*.springMVC</url-pattern>  
  33.     </servlet-mapping>  
  34.   
  35.   
  36.     <servlet>  
  37.         <display-name>DWR Servlet</display-name>  
  38.         <servlet-name>dwr-invoker</servlet-name>  
  39.         <servlet-class>  
  40.             org.directwebremoting.servlet.DwrServlet  
  41.         </servlet-class>  
  42.         <init-param>  
  43.             <param-name>debug</param-name>  
  44.             <param-value>true</param-value>  
  45.         </init-param>  
  46.         <init-param>  
  47.             <param-name>activeReverseAjaxEnabled</param-name>  
  48.             <param-value>true</param-value>  
  49.         </init-param>  
  50.         <init-param>  
  51.             <param-name>  
  52.                 initApplicationScopeCreatorsAtStartup  
  53.             </param-name>  
  54.             <param-value>true</param-value>  
  55.         </init-param>  
  56.         <init-param>  
  57.             <param-name>maxWaitAfterWrite</param-name>  
  58.             <param-value>500</param-value>  
  59.         </init-param>  
  60.         <load-on-startup>1</load-on-startup>  
  61.     </servlet>  
  62.     <servlet-mapping>  
  63.         <servlet-name>dwr-invoker</servlet-name>  
  64.         <url-pattern>/dwr/*</url-pattern>  
  65.     </servlet-mapping>  
  66.   
  67.     <welcome-file-list>  
  68.         <welcome-file>test/RegisterUser.html</welcome-file>  
  69.     </welcome-file-list>  
  70. </web-app>  

RegisterUser.html
java 代码
 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3.     <head>  
  4.         <title>Register User</title>  
  5.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
  6.         <script type='text/javascript' src='../dwr/engine.js'></script>  
  7.         <script type='text/javascript' src='../dwr/util.js'></script>  
  8.         <script type='text/javascript' src='../dwr/interface/UserService.js'></script>  
  9.         <script type='text/javascript' src='js/RegisterUser.js'></script>  
  10.     </head>  
  11.     <body>  
  12.         <input type="text" id="userName" onblur="regUserChked();" />  
  13.         <input type="button" value="检验" onclick="regUserChked();" />  
  14.         <div id="userMsg"></div>  
  15.     </body>  
  16. </html>  


RegisterUser.js
js 代码
 
  1. function regUserChked() {  
  2.     var userName = document.getElementById("userName");  
  3.     UserService.isExist(userName.value, showData);//showData回调函数     
  4. }  
  5. function showData(data) {  
  6.     if (data) {  
  7.         DWRUtil.setValue("userMsg""\u8be5\u7528\u6237\u540d\u5df2\u7ecf\u88ab\u6ce8\u518c\uff0c\u8bf7\u66f4\u6362\u60a8\u7684\u7528\u6237\u540d\uff01");  
  8.     } else {  
  9.         DWRUtil.setValue("userMsg""\u606d\u559c\u60a8\uff0c\u8be5\u7528\u6237\u540d\u5c1a\u672a\u88ab\u6ce8\u518c\uff01");  
  10.     }  
  11. }  
   发表时间:2007-11-22  
可能是配置spring的xml不正确吧.导致找不到
<param name="location" value="applicationContext.xml"/>
 
<context-param>  
        <param-name>contextConfigLocation</param-name>  
        <param-value>  
            /WEB-INF/classes/applicationContext.xml  
        </param-value>  
    </context-param
0 请登录后投票
   发表时间:2007-11-22  
不要指定location,指定了以后不是指定文件中的bean就不能生成了
试一下,把location删掉
0 请登录后投票
   发表时间:2007-11-27  
把id="userService"改为name="userService"试试看
0 请登录后投票
   发表时间:2008-01-06  
在dwr.xml里 不需要这个了吧
<param name="location" value="applicationContext.xml"/> 
0 请登录后投票
   发表时间:2008-07-25  
出现了同样的问题,LZ是怎么解决的???找了很多地方没找出原因
0 请登录后投票
论坛首页 入门技术版

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