spring mvc base init
This commit is contained in:
		
							
								
								
									
										1
									
								
								spring/springmvc-base/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								spring/springmvc-base/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
springmvc-base
 | 
			
		||||
							
								
								
									
										44
									
								
								spring/springmvc-base/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								spring/springmvc-base/pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
 | 
			
		||||
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
			
		||||
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 | 
			
		||||
    <modelVersion>4.0.0</modelVersion>
 | 
			
		||||
 | 
			
		||||
    <groupId>com.heibaiying</groupId>
 | 
			
		||||
    <artifactId>springmvc-base</artifactId>
 | 
			
		||||
    <version>1.0-SNAPSHOT</version>
 | 
			
		||||
 | 
			
		||||
    <properties>
 | 
			
		||||
        <spring-base-version>5.1.3.RELEASE</spring-base-version>
 | 
			
		||||
    </properties>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    <dependencies>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.springframework</groupId>
 | 
			
		||||
            <artifactId>spring-context</artifactId>
 | 
			
		||||
            <version>${spring-base-version}</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.springframework</groupId>
 | 
			
		||||
            <artifactId>spring-beans</artifactId>
 | 
			
		||||
            <version>${spring-base-version}</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.springframework</groupId>
 | 
			
		||||
            <artifactId>spring-core</artifactId>
 | 
			
		||||
            <version>${spring-base-version}</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.springframework</groupId>
 | 
			
		||||
            <artifactId>spring-web</artifactId>
 | 
			
		||||
            <version>${spring-base-version}</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.springframework</groupId>
 | 
			
		||||
            <artifactId>spring-webmvc</artifactId>
 | 
			
		||||
            <version>${spring-base-version}</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
    </dependencies>
 | 
			
		||||
 | 
			
		||||
</project>
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
package com.heibaiying.controller;
 | 
			
		||||
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author : heibaiying
 | 
			
		||||
 * @description : hello spring
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@Controller
 | 
			
		||||
@RequestMapping("mvc")
 | 
			
		||||
public class HelloController {
 | 
			
		||||
 | 
			
		||||
    @RequestMapping("hello")
 | 
			
		||||
    private String hello() {
 | 
			
		||||
        return "hello";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<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 http://www.springframework.org/schema/context/spring-context-4.1.xsd
 | 
			
		||||
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
 | 
			
		||||
 | 
			
		||||
    <!-- 开启注解包扫描-->
 | 
			
		||||
    <context:component-scan base-package="com.heibaiying.*"/>
 | 
			
		||||
 | 
			
		||||
    <!--使用默认的Servlet来响应静态文件 详见README.md -->
 | 
			
		||||
    <mvc:default-servlet-handler/>
 | 
			
		||||
 | 
			
		||||
    <!-- 开启注解驱动 详见 README.md -->
 | 
			
		||||
    <mvc:annotation-driven/>
 | 
			
		||||
 | 
			
		||||
    <!-- 配置视图解析器 -->
 | 
			
		||||
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
 | 
			
		||||
          id="internalResourceViewResolver">
 | 
			
		||||
        <!-- 前缀 -->
 | 
			
		||||
        <property name="prefix" value="/WEB-INF/jsp/"/>
 | 
			
		||||
        <!-- 后缀 -->
 | 
			
		||||
        <property name="suffix" value=".jsp"/>
 | 
			
		||||
    </bean>
 | 
			
		||||
</beans>
 | 
			
		||||
@@ -0,0 +1,9 @@
 | 
			
		||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
    <title>Title</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
    Hello Spring MVC!
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										24
									
								
								spring/springmvc-base/src/main/webapp/WEB-INF/web.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								spring/springmvc-base/src/main/webapp/WEB-INF/web.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
 | 
			
		||||
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
			
		||||
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
 | 
			
		||||
		 http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
 | 
			
		||||
         version="3.1">
 | 
			
		||||
 | 
			
		||||
    <!--配置spring前端控制器-->
 | 
			
		||||
    <servlet>
 | 
			
		||||
        <servlet-name>springMvc</servlet-name>
 | 
			
		||||
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 | 
			
		||||
        <init-param>
 | 
			
		||||
            <param-name>contextConfigLocation</param-name>
 | 
			
		||||
            <param-value>classpath:springApplication.xml</param-value>
 | 
			
		||||
        </init-param>
 | 
			
		||||
        <load-on-startup>1</load-on-startup>
 | 
			
		||||
    </servlet>
 | 
			
		||||
 | 
			
		||||
    <servlet-mapping>
 | 
			
		||||
        <servlet-name>springMvc</servlet-name>
 | 
			
		||||
        <url-pattern>/</url-pattern>
 | 
			
		||||
    </servlet-mapping>
 | 
			
		||||
 | 
			
		||||
</web-app>
 | 
			
		||||
							
								
								
									
										9
									
								
								spring/springmvc-base/src/main/webapp/index.jsp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								spring/springmvc-base/src/main/webapp/index.jsp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
    <title>index</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
    INDEX!
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
		Reference in New Issue
	
	Block a user