简体   繁体   English

将DWR添加到SpringMVC,但是没有效果。当我访问一个Controller时,在控制台中抛出错误

[英]Add DWR to SpringMVC,but there is no effective.When I access one Controller, throw an Error in console

Add DWR to SpringMVC,but there is no effective.When I access one Controller, throw an Error in console. 将DWR添加到SpringMVC,但是没有效果。当我访问一个Controller时,在控制台中抛出错误。

LOG: org.springframework.web.servlet.PageNotFound noHandlerFound Warn: No mapping found for HTTP request with URI [/YouthDesign/reverseAjax/toPeopleTable] in DispatcherServlet with name 'springmvc' 日志:org.springframework.web.servlet.PageNotFound noHandlerFound警告:在DispatcherServlet中,名称为“ springmvc”的URI [/ YouthDesign / reverseAjax / toPeopleTable]的HTTP请求未找到映射

web.xml web.xml中

 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Touth Design</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:/application-cfg.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:/springmvc-cfg.xml, classpath*:/dwr-cfg.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- <servlet> <servlet-name>dwr</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>activeReverseAjaxEnabled</param-name> <param-value>true</param-value> </init-param> </servlet> --> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> 

springmvc-cfg.xml 用SpringMVC-cfg.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" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"> <context:component-scan base-package="com.youthdesign.web"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan> <mvc:annotation-driven /> <!-- 映射静态资源 --> <mvc:resources location="/static/" mapping="/resources/**"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp"/> </bean> </beans> 

dwr-cfg.xml DWR-cfg.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" xmlns:context="http://www.springframework.org/schema/context" xmlns:spring-dwr="http://www.directwebremoting.org/schema/spring-dwr" xsi:schemaLocation="http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"> <spring-dwr:configuration /> <spring-dwr:url-mapping /> <spring-dwr:controller id="dwrController" debug="true"> <spring-dwr:config-param name="activeReverseAjaxEnabled" value="true"/> </spring-dwr:controller> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="alwaysUseFullPath" value="true"/> <property name="mappings"> <props> <prop key="/dwr/**/*">dwrController</prop> </props> </property> </bean> <spring-dwr:annotation-scan base-package="com.youthdesign" scanDataTransferObject="true" scanRemoteProxy="true"/> </beans> 

Above are my config files,please help,thank you all. 以上是我的配置文件,请帮助,谢谢大家。

I have fix this problem.If you are learning dwr and want to use it with spring together.You can refer to my demo on Github. 我已经解决了这个问题。如果您正在学习dwr并想与spring一起使用,请参阅我在Github上的演示。 https://github.com/BigRui/simpleDWR https://github.com/BigRui/simpleDWR

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM