找不到URI为[/webstore]的HTTP请求的映射



我在tomcat服务器上运行spring应用程序时遇到问题。我在浏览器中得到错误404,在控制台中得到这个:

2016-05-09 12:26:03,188 INFO org.hibernate.tool.hbm2ddl.SchemaExport -  HHH000230: Schema export complete
2016-05-09 12:26:05,082 INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'DispatcherServlet': initialization completed in 5685 ms
2016-05-09 12:26:05,121 WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/webstore/] in DispatcherServlet with name 'DispatcherServlet'

这是我的web.xml文件:

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                             http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<filter>
    <filter-name>encoding-filter</filter-name>
    <filter-class>
        org.springframework.web.filter.CharacterEncodingFilter
    </filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
    <param-name>forceEncoding</param-name>
    <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>encoding-filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
    <servlet-name>DispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring/webcontext/DispatcherServlet-context.xml
        </param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>DispatcherServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
/WEB-INF/spring/webcontext/security-context.xml 

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener 
    </listener-class>
</listener>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
        org.springframework.web.filter.DelegatingFilterProxy
</filter-class>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

你能告诉我出了什么问题吗?这很奇怪,因为我不是唯一一个使用此代码的人,而且只有我有这个问题。。。

哦。我的DispatcherServlet.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"
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-4.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

<import resource="classpath:spring/database-context.xml" />
<mvc:annotation-driven enable-matrix-variables="true">
    <mvc:message-converters>
        <bean
            class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
            <property name="objectMapper" ref="jsonObjectMapper" />
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>
<context:component-scan base-package="pl.spring.demo" />
<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="messages" />
</bean>
<bean id="jsonObjectMapper"
    class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
    <property name="objectMapper">
        <bean class="com.fasterxml.jackson.databind.ObjectMapper" />
    </property>
</bean>

您需要在应用程序服务器中检查以下几点:

  • 是否存在任何部署错误消息
  • 应用程序已部署,但具有不同的上下文?(例如/而不是/webstore
  • 您的应用程序服务器有多个副本,但您正在运行一个副本,并试图在另一个副本中部署应用程序吗

最新更新