tomcat访问mvc的controller层注解报错404

sprng-mvc配置

<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 https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--配置扫描器-->
    <context:component-scan base-package="com.hbsy.controller"/>
<!--    配置注解驱动-->
    <mvc:annotation-driven/>
<!--    试图解析器-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
</beans>

web.xml配置

<!--    加载mvc-->
    <servlet>
        <servlet-name>dispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring-mvc.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>

controller层

@Controller
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/toLogin")
    public String jump(){
        return "login";
    }

}

报错

img

没看到项目名称呢?在地址栏里面加上项目名称再试试.

如果你是自己从java项目改造成web项目,即使你配置全对,也会出现这种情况,上次有个小老弟就是这样,1种是打包后resource丢失,一种运行后直接是jar丢失