Java 正在尝试升级到Spring4无xml配置webapp

Java 正在尝试升级到Spring4无xml配置webapp,java,spring-mvc,annotations,spring-4,Java,Spring Mvc,Annotations,Spring 4,我正在尝试使用Spring4构建一个HelloWorldWebApp原型,不需要任何xml文件配置 然后我使用tomcat 7,下面是我的pom: <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <ve

我正在尝试使用Spring4构建一个HelloWorldWebApp原型,不需要任何xml文件配置

然后我使用tomcat 7,下面是我的pom:

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.0.6.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
</dependencies>
和web初始值设定项类:

public class HelloWorldInitializer extends 
AbstractAnnotationConfigDispatcherServletInitializer {

@Override
protected Class<?>[] getRootConfigClasses() {
    return new Class[] { HelloWorldConfiguration.class };
}

@Override
protected Class<?>[] getServletConfigClasses() {
    return null;
}

@Override
protected String[] getServletMappings() {
    return new String[] { "/" };
}

}
以及WEB-INF下包含welcome.jsp的文件夹视图:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>HelloWorld page</title>
 </head>
 <body>
   Greeting : ${greeting}
 </body>
</html>

该死。。我没有下载这个示例,我只是复制eclipse中的代码。。。我没有maven项目,我使用maven只是为了解决依赖关系(在配置->转换为maven项目之后,我创建了一个动态Web项目),而不是通常在服务器上运行它。我有许多使用Spring4如上所述构建的项目,它们工作得非常好

我不知道为什么我不能启动这个。代码很简单,功能不依赖于maven配置


谢谢

以下URL的代码运行良好


请检查您的URL

您遇到了什么错误?
@Controller
@RequestMapping("/")
public class HelloWorldController {

@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String sayHello(ModelMap model) {
    model.addAttribute("greeting", "Hello World from Spring 4 MVC");
    return "welcome";
}

@RequestMapping(value = "/helloagain", method = RequestMethod.GET)
public String sayHelloAgain(ModelMap model) {
    model.addAttribute("greeting", "Hello World Again, from Spring 4 MVC");
    return "welcome";
}

}
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>HelloWorld page</title>
 </head>
 <body>
   Greeting : ${greeting}
 </body>
</html>
HTTP Status 404 – Not Found
Type Status Report

Message /Spring4FullAnnotation/

Description The origin server did not find a current representation for the 
target resource or is not willing to disclose that one exists.