org.springframework.web.servlet.DispatcherServlet noHandlerFound

错误提示:

org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/spring/test] in DispatcherServlet with name 'spring'

错误代码:@RequestMapping(name="/test")

正确代码:@RequestMapping(value="/test")

源码的注释:

/**
     * Assign a name to this mapping.
     * <p><b>Supported at the type level as well as at the method level!</b>
     * When used on both levels, a combined name is derived by concatenation
     * with "#" as separator.
     * @see org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder
     * @see org.springframework.web.servlet.handler.HandlerMethodMappingNamingStrategy
     */
    String name() default "";

/**
     * The primary mapping expressed by this annotation.
     * <p>In a Servlet environment this is an alias for {@link #path}.
     * For example {@code @RequestMapping("/foo")} is equivalent to
     * {@code @RequestMapping(path="/foo")}.
     * <p>In a Portlet environment this is the mapped portlet modes
     * (i.e. "EDIT", "VIEW", "HELP" or any custom modes).
     * <p><b>Supported at the type level as well as at the method level!</b>
     * When used at the type level, all method-level mappings inherit
     * this primary mapping, narrowing it for a specific handler method.
     */
    @AliasFor("path")
    String[] value() default {};

  这个错误搞了好久,因为凭着记忆写的,却偏偏将value误写成name,后台没有明显的提示错误信息,只是警告,所以就一直以为是配置信息有问题,一遍一遍的检测配置信息,一遍一遍的创建新的项目,一遍一遍的启动项目,真的是一手失成千古恨。

原文地址:https://www.cnblogs.com/July74/p/5216021.html