Java Spring配置:在名为';dispatcherServlet';

Java Spring配置:在名为';dispatcherServlet';,java,spring,spring-mvc,Java,Spring,Spring Mvc,我认为配置文件中缺少某些内容,但我看不到 当我在浏览器-->localhost:8080/Procura/notifications-->中输入时,我会在控制台中看到这个--> org.springframework.web.servlet.DispatcherServlet noHandlerFound 警告:在名为“DispatcherServlet”的DispatcherServlet中找不到URI为[/Procura/notifications]的HTTP请求的映射。 xml(我也尝试过

我认为配置文件中缺少某些内容,但我看不到

当我在浏览器-->localhost:8080/Procura/notifications-->中输入时,我会在控制台中看到这个--> org.springframework.web.servlet.DispatcherServlet noHandlerFound 警告:在名为“DispatcherServlet”的DispatcherServlet中找不到URI为[/Procura/notifications]的HTTP请求的映射。

xml(我也尝试过3.0)

项目结构

我认为
与@RequestMapping注释相冲突。
如果要使用带注释的请求映射将请求url映射到控制器,请尝试从spring mvc配置中删除BeanNameUrlHandlerMapping,显然Tomcat已损坏。但现在一切都正常了

第一个偶数让dispatcherServlet阻塞后缀,例如:*.do; 为了不阻塞jsp后缀,第二种方法是添加spring-servlet.xml
mvc:默认servlet处理程序

服务器启动期间是否有错误和警告?@FredericClose-->当我在浏览器-->localhost:8080/Procura/notifications-->中输入控制台时,我发现此-->org.springframework.web.servlet.DispatcherServlet noHandlerFound Warnung:未找到URI为[/Procura/notifications]的HTTP请求的映射在名为“DispatcherServlet”的DispatcherServlet中。但是服务器启动是正确的是的,但是服务器启动呢,或者当部署应用程序时呢?当我启动服务器时,一切都是正确的,部署也是正确的。尝试将
上下文:组件扫描更改为此
,我不知道是否有任何冲突,但是如果我从xml中删除这一行,我收到了相同的错误。您能为spring启用调试日志并提供日志吗?另外,如果war的名称是Procura.war,您能否确认您是如何部署应用程序的?
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.5" 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_2_5.xsd">

<display-name>Procura</display-name>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/application-config.xml</param-value>
</context-param>

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

<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/mvc-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcherServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>
<?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:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="
        http://www.springframework.org/schema/jdbc
        http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-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/jee
        http://www.springframework.org/schema/jee/spring-jee-3.2.xsd">

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">
            <value>com.mysql.jdbc.Driver</value>
        </property>
        <property name="url">
            <value>jdbc:mysql://localhost:3306/procura</value>
        </property>
        <property name="username">
            <value>procura</value>
        </property>
        <property name="password">
            <value>procura</value>
        </property>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="com.procura.model" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
                <prop key="hibernate.max_fetch_depth">3</prop>
                <prop key="hibernate.jdbc.fetch_size">50</prop>
                <prop key="hibernate.jdbc.batch_size">10</prop>
                <prop key="hibernate.show_sql">true</prop>
            </props>
        </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager"/>

    <context:component-scan base-package="com.procura.service"/>

</beans>
<?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:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="
        http://www.springframework.org/schema/jdbc
        http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-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/jee
        http://www.springframework.org/schema/jee/spring-jee-3.2.xsd">

    <mvc:annotation-driven />

    <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
    <mvc:resources mapping="/resources/**" location="/resources/" />

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

    <context:component-scan base-package="com.procura.controller" />

</beans>
package com.procura.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class NotificationController {

    final Logger logger = LoggerFactory.getLogger(NotificationController.class);

    @RequestMapping(value = "/notifications")
    public String listAll(Model uiModel) {
        System.out.println("In method");
        logger.info("Listing notifications");
        return "notifications/list";
    }
}