“/”请求出错404错误

时间:2013-12-26 20:28:43

标签: spring spring-mvc

我的项目yous存在问题:http://localhost:8080/yous/cc它有效,但http://localhost:8080/yous/我得404 error

déc. 26, 2013 8:37:26 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
Avertissement: No mapping found for HTTP request with URI [/yous/] in DispatcherServlet with name 'appServlet'

我的控制器:

@RequestMapping(value = "/cc")
public String printWelcome() {
    System.out.println("Hello");
    return "/WEB-INF/pages/hello.jsp";

}

@RequestMapping(value = "/")
public String printIndex() {
    return "index.html";

}

我的web.xml

    <servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>appServlet-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

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

我的appServlet-servlet.xml

<context:component-scan base-package="controller"/>
<mvc:annotation-driven />

1 个答案:

答案 0 :(得分:0)

我们用

解决问题
@RequestMapping(value="/index") 

似乎/index处理/,有人可以解释为什么吗?