- yangyanninhao
- 等级: 初级会员
- 文章: 13
- 积分: 50
- 来自: ...
|
我想整合Spring2 与 DWR2但是总是提示:UserService is not defined !
不清楚是什么地方出现的问题,在网上搜索了一些资料都是这样配置的,希望大家帮我看一下是什么地方出现问题。
谢谢大家了,下面是相关配置文件。
ApplicationContext.xml :
xml 代码
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
-
- <bean id="userService"
- class="org.Spring2AndDWR2.test.service.impl.UserServiceImpl"></bean>
- </beans>
dwr.xml
xml 代码
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://www.getahead.ltd.uk/dwr/dwr20.dtd">
- <dwr>
- <allow>
- <create creator="spring" javascript="UserService">
- <param name="beanName" value="userService"/>
- <param name="location" value="applicationContext.xml"/>
- </create>
- </allow>
- </dwr>
web.xml
xml 代码
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
- http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
-
- <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>
-
- <servlet>
- <servlet-name>Dispatcher</servlet-name>
- <servlet-class>
- org.springframework.web.servlet.DispatcherServlet
- </servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/classes/Spring2AndDWR2-servlet.xml</param-value>
- </init-param>
- </servlet>
- <servlet-mapping>
- <servlet-name>Dispatcher</servlet-name>
- <url-pattern>*.springMVC</url-pattern>
- </servlet-mapping>
-
-
- <servlet>
- <display-name>DWR Servlet</display-name>
- <servlet-name>dwr-invoker</servlet-name>
- <servlet-class>
- org.directwebremoting.servlet.DwrServlet
- </servlet-class>
- <init-param>
- <param-name>debug</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>activeReverseAjaxEnabled</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>
- initApplicationScopeCreatorsAtStartup
- </param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>maxWaitAfterWrite</param-name>
- <param-value>500</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>dwr-invoker</servlet-name>
- <url-pattern>/dwr/*</url-pattern>
- </servlet-mapping>
-
- <welcome-file-list>
- <welcome-file>test/RegisterUser.html</welcome-file>
- </welcome-file-list>
- </web-app>
RegisterUser.html
java 代码
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Register User</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <script type='text/javascript' src='../dwr/engine.js'></script>
- <script type='text/javascript' src='../dwr/util.js'></script>
- <script type='text/javascript' src='../dwr/interface/UserService.js'></script>
- <script type='text/javascript' src='js/RegisterUser.js'></script>
- </head>
- <body>
- <input type="text" id="userName" onblur="regUserChked();" />
- <input type="button" value="检验" onclick="regUserChked();" />
- <div id="userMsg"></div>
- </body>
- </html>
RegisterUser.js
js 代码
- function regUserChked() {
- var userName = document.getElementById("userName");
- UserService.isExist(userName.value, showData);
- }
- function showData(data) {
- if (data) {
- DWRUtil.setValue("userMsg", "\u8be5\u7528\u6237\u540d\u5df2\u7ecf\u88ab\u6ce8\u518c\uff0c\u8bf7\u66f4\u6362\u60a8\u7684\u7528\u6237\u540d\uff01");
- } else {
- DWRUtil.setValue("userMsg", "\u606d\u559c\u60a8\uff0c\u8be5\u7528\u6237\u540d\u5c1a\u672a\u88ab\u6ce8\u518c\uff01");
- }
- }
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
返回顶楼 |
|
|
- saturn
- 等级: 初级会员
- 性别:
- 文章: 94
- 积分: 9
- 来自: 修真界
|
可能是配置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
|
返回顶楼 |
|
|
|
不要指定location,指定了以后不是指定文件中的bean就不能生成了
试一下,把location删掉
|
返回顶楼 |
|
|
- zjnbhwh
- 等级: 初级会员
- 文章: 10
- 积分: 30
- 来自: ...
|
把id="userService"改为name="userService"试试看
|
返回顶楼 |
|
|
- libinwalan
- 等级: 初级会员
- 性别:
- 文章: 12
- 积分: 30
- 来自: 成都
|
在dwr.xml里 不需要这个了吧 <param name="location" value="applicationContext.xml"/>
|
返回顶楼 |
|
|
- hunterzhang
- 等级: 初级会员
- 性别:
- 文章: 17
- 积分: 0
- 来自: 深圳
|
出现了同样的问题,LZ是怎么解决的???找了很多地方没找出原因
|
返回顶楼 |
|
|