文件夹:
springmvc_第一个简单的入门程序_xml
首先确定环境

pom.xml



xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

com.Zjy
SpringMvc_Demo01
1.0-SNAPSHOT
war

SpringMvc_Demo01 Maven Webapp

http://www.example.com


UTF-8
1.8
1.8
5.0.2.RELEASE




org.springframework
spring-context
${spring.version}



org.springframework
spring-web
${spring.version}



org.springframework
spring-webmvc
${spring.version}



javax.servlet
servlet-api
2.5
provided



javax.servlet.jsp
jsp-api
2.0
provided




SpringMvc_Demo01



maven-clean-plugin
3.0.0



maven-resources-plugin
3.0.2


maven-compiler-plugin
3.7.0


maven-surefire-plugin
2.20.1


maven-war-plugin
3.2.0


maven-install-plugin
2.5.2


maven-deploy-plugin
2.8.2





index.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>


Title


入门


入门



web.xml

 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >


Archetype Created Web Application

dispatcherServlet
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:springmvc.xml

1


dispatcherServlet
/


success.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>


Title


success





springmvc.xml


xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">







开启注解扫描
配置需要加载的bean
启动springmvc注解

Demo01.java

@Controller
public class Demo01 {
@RequestMapping(path = "/hello")
public String hello(){
System.out.println("springmvc");
return "success";
}
}

需要配置tomcat
springmvc_第一个简单的入门程序_spring_02

启动
springmvc_第一个简单的入门程序_spring_03

->
springmvc_第一个简单的入门程序_xml_04
注意这里的pom与springmvc.xml信息的内容.大多有改造