如果使用mvc-dispatcher-servlet.xml

时间:2017-09-14 05:53:00

标签: java spring spring-mvc tomcat servlets

在gradle web项目中,我只想加载mvc-dispatcher-servlet,但是当我通过在tomcat控制台中部署以下异常来启动tomcat时:

enter image description here

web.xml:

<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>/api/*</url-pattern>
</servlet-mapping>

<!-- <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> -->
  

你可以看到我已经注释了contextLoaderListener仍在加载   的applicationContext.xml。

MVC-调度-servlet.xml中

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:util="http://www.springframework.org/schema/util" 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-3.2.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/oxm
    http://www.springframework.org/schema/oxm/spring-oxm.xsd
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-3.2.xsd">


    <context:component-scan base-package="<package-name>" />

 <mvc:annotation-driven />

请帮帮我。我也跟踪了文档和stackoverflow,但没有找到解决方案。

提前感谢您帮助我!

  

注意:我使用的是spring v.4.2.4,我也试过4.3.10但是   没用。

0 个答案:

没有答案