spring和DWR映射问题

时间:2013-05-13 00:04:31

标签: spring-mvc dwr

与DWR集成时,我遇到弹簧MVC映射问题。问题是,我不能让他们一起工作。我想在我的jsp中使用dwr服务,但是当dwr映射工作时,spring不会和相反。

的web.xml

<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">

    <display-name>Spring MVC Application</display-name>

    <servlet>
        <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>


    <listener>
        <listener-class>
            SpringListeners.MySessionListener
        </listener-class>
    </listener>
    <session-config>
        <session-timeout>1</session-timeout>
    </session-config>

</web-app>

MVC-调度员servler.xml

<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:dwr="http://www.directwebremoting.org/schema/spring-dwr"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="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.xsd http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

    <context:component-scan base-package="com.springapp.mvc"/>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
    </bean>


    <dwr:controller id="dwrController" debug="true">
        <dwr:config-param name="activeReverseAjaxEnabled" value="true"/>
        <dwr:config-param name="scriptCompressed" value="true"/>
        <dwr:config-param name="fileUploadMaxBytes" value="10485760"/>
        <dwr:config-param name="allowScriptTagRemoting" value="true"/>
    </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>



    <bean id="Player" class="dwr.Player" scope="session">
        <dwr:remote javascript="Player">
            <!--<dwr:include method="" />-->
        </dwr:remote>
        <aop:scoped-proxy proxy-target-class="false"/>
    </bean>

</beans>

现在dwr在调试模式下工作,但所有其他弹簧映射都没有。当我删除

<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>

dwr不起作用,但弹簧映射确实有效。这是我用来测试弹簧映射的控制器

@Controller
@RequestMapping("/")
public class HelloController {
    @RequestMapping(method = RequestMethod.GET)
    public String printWelcome(ModelMap model) {
        System.out.println("agaga");
        model.addAttribute("message", "Hello world!");

        return "hello";
    }
}

0 个答案:

没有答案