项目启动弹簧mvc上没有请求的资源

时间:2016-04-22 17:32:31

标签: spring spring-mvc tomcat

为什么我在项目启动时找不到所请求的资源,即使一切似乎都没问题

<context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>classpath:log4j.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

请帮助我!!!

1 个答案:

答案 0 :(得分:0)

您需要使用org.springframework.web.context.ContextLoaderListener加载Spring上下文,而不是Log4jConfigListener(或尝试Spring Boot)

请参阅Loading context in Spring using web.xml