0

我正在使用组件扫描来扫描我的所有控制器和注释配置以进行自动装配。我也在使用 mvc:annotation 驱动和 tx:annotation-driven。我的网络应用程序运行良好,但在启动期间所有请求映射都被扫描了两次。我得到如下日志。

Mapped URL path [/mdm/searchDevice] onto handler 'mdmController'
2386 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO Mapped URL path [/mdm/searchDevice.*] onto handler 'mdmController'
2386 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO Mapped URL path [/mdm/searchDevice/] onto handler 'mdmController'
2760 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO org.apache.tiles.context.AbstractTilesApplicationContextFactory - Finished initializing Tiles2 application context.
2386 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO Mapped URL path [/mdm/searchDevice.*] onto handler 'mdmController'
2386 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] INFO Mapped URL path [/mdm/searchDevice/] onto handler 'mdmController' 

/mdm/searchDevice/ 被扫描两次。

我的 spring-servlet.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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd">

    <context:component-scan base-package="com.tcs.mpos">
        <context:include-filter expression="org.springframework.stereotype.Controller"
            type="annotation" />
    </context:component-scan>

    <mvc:annotation-driven />

    <context:annotation-config />

    <tx:annotation-driven />

    <bean id="tilesViewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <!-- <property name="order" value="0"/> -->
        <property name="viewClass">
            <value>
                org.springframework.web.servlet.view.tiles2.TilesView
            </value>
        </property>
    </bean>

    <bean id="tilesConfigurer"
        class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles.xml</value>
            </list>
        </property>
    </bean>
</beans>
4

0 回答 0