请求的资源(/)不可用
我刚刚开始学习Spring MVC 3,我在开始时遇到问题就是运行简单的hello world程序
我试图让它运行起来,但我不能出于某种原因
我经常遇到这个错误
type Status report message / description The requested resource (/) is not available.
这是我的servlet-context.xml
文件
web.xml
文件
contextConfigLocation /WEB-INF/spring/root-context.xml org.springframework.web.context.ContextLoaderListener appServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/spring/appServlet/servlet-context.xml 1 appServlet /
HomeController.java
package com.test.test;
import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class HomeController { @RequestMapping(value = "/") public String home() { return "WEB-INF/views/home.jsp"; } }
我正在使用Tomcat 7。
任何人都知道什么是cosign这个错误?
@Tenelope你不需要返回"WEB-INF/views/home.jsp";
您可以在servlet上下文中配置它,只需返回"home"
:
我给你的建议是下载spring源码(像IDE一样的eclipse):
http://www.springsource.org/springsource-tool-suite-download
下载后,您只需转到File > New > Spring Template Project > Spring MVC project
完成项目创建后,将为您创建工作模板项目(结构化项目,示例控制器文件,示例视图,pom.xml等)。 包括您正在谈论的"/"
示例。 您可以构建它并将其部署到tomcat或其他任何东西。
通过这种方式,您已经获得了工作示例,您可以从那里获取它。
顺便说一句。 看一下这个 :
https://github.com/SpringSource/spring-mvc-showcase/blob/master/MasteringSpringMVC3.pdf?raw=true
这足以让你开始使用Spring MVC。