Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 784c579

Browse files
author
zwd-admin
committed
zwd
1 parent 302bcf6 commit 784c579

File tree

78 files changed

+6972
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+6972
-4
lines changed

pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323

2424
<build>
2525
<plugins>
26-
<plugin>
27-
<groupId>org.springframework.boot</groupId>
28-
<artifactId>spring-boot-maven-plugin</artifactId>
29-
</plugin>
3026
<plugin>
3127
<groupId>org.apache.maven.plugins</groupId>
3228
<artifactId>maven-compiler-plugin</artifactId>

spring5/my-spring-mvc/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
### 启动说明
2+
本项目使用maven tomcat的插件进行启动,也可以打包放入tomcat中。
3+
4+
#### tomcat插件配置
5+
```xml
6+
<plugin>
7+
<groupId>org.apache.tomcat.maven</groupId>
8+
<artifactId>tomcat7-maven-plugin</artifactId>
9+
<version>2.1</version>
10+
<configuration>
11+
<!--<url>http://localhost:8080/data</url>-->
12+
<!--<server>tomcat7-local</server>-->
13+
<!--项目名称根路径-->
14+
<path>/my-spring-mvc</path>
15+
</configuration>
16+
17+
</plugin>
18+
```
19+
本人使用idea做为开发工具,这里展示idea配置过程。
20+
![](./image/tomcat-config.png)
21+
22+
23+
启动成功即可访问。(如果没有tag 请看本人仓库原项目spring-mvc)
24+
25+
* tag v1.0.0 通过自定义反射实现mvc
26+
27+
* tag v1.0.1 基于编码替换web.xml
28+
29+
* tag v1.1.0 模拟spring mvc初始化web.xml和applicationContext.xml
30+
31+
* tag v2.0.0 可以正常使用,但不包含对redirect和forward的处理
32+
33+
* tag v2.0.1 增加对redirect和forward的处理
34+
35+
* tag v2.0.2 增加对请求参数的支持
36+
37+
* tag v2.0.3 增加对ModelAndView的支持
24.6 KB
Loading

spring5/my-spring-mvc/pom.xml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>spring5</artifactId>
7+
<groupId>com.java.advance</groupId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>my-spring-mvc</artifactId>
13+
14+
<packaging>war</packaging>
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
18+
<java.version>1.8</java.version>
19+
<spring.version>5.0.6.RELEASE</spring.version>
20+
<servlet-api.version>3.1.0</servlet-api.version>
21+
<jstl.version>1.2</jstl.version>
22+
</properties>
23+
<dependencies>
24+
<!-- Servlet 3.1 API 依赖-->
25+
<dependency>
26+
<groupId>javax.servlet</groupId>
27+
<artifactId>javax.servlet-api</artifactId>
28+
<version>${servlet-api.version}</version>
29+
<scope>provided</scope>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>javax.servlet</groupId>
34+
<artifactId>jstl</artifactId>
35+
<version>${jstl.version}</version>
36+
</dependency>
37+
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
38+
<dependency>
39+
<groupId>org.springframework</groupId>
40+
<artifactId>spring-beans</artifactId>
41+
<version>${spring.version}</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.springframework</groupId>
45+
<artifactId>spring-core</artifactId>
46+
<version>${spring.version}</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.springframework</groupId>
50+
<artifactId>spring-aop</artifactId>
51+
<version>${spring.version}</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.springframework</groupId>
55+
<artifactId>spring-expression</artifactId>
56+
<version>${spring.version}</version>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.springframework</groupId>
60+
<artifactId>spring-web</artifactId>
61+
<version>${spring.version}</version>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.springframework</groupId>
65+
<artifactId>spring-context</artifactId>
66+
<version>${spring.version}</version>
67+
</dependency>
68+
</dependencies>
69+
70+
71+
<build>
72+
<plugins>
73+
<plugin>
74+
<groupId>org.apache.tomcat.maven</groupId>
75+
<artifactId>tomcat7-maven-plugin</artifactId>
76+
<version>2.1</version>
77+
<configuration>
78+
<!--<url>http://localhost:8080/data</url>-->
79+
<!--<server>tomcat7-local</server>-->
80+
<!--项目名称根路径-->
81+
<path>/my-spring-mvc</path>
82+
</configuration>
83+
84+
</plugin>
85+
</plugins>
86+
<resources>
87+
<resource>
88+
<directory>src/main/java</directory>
89+
<includes>
90+
<include>**/*.properties</include>
91+
</includes>
92+
</resource>
93+
</resources>
94+
</build>
95+
</project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.zwd.web.controller;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.InitBinder;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.servlet.MyModelAndView;
8+
9+
/**
10+
* TODO...
11+
*
12+
* @author zwd
13+
* @since 2019-04-22
14+
**/
15+
@Controller
16+
public class HelloController {
17+
18+
@GetMapping(value = "hello")
19+
public MyModelAndView index(String name, MyModelAndView modelAndView) {
20+
21+
modelAndView.addObject("message",name);
22+
modelAndView.setViewName("index");
23+
return modelAndView;
24+
}
25+
26+
@RequestMapping(value = "getname")
27+
public String getName() {
28+
29+
return "index";
30+
}
31+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Default implementation classes for DispatcherServlet's strategy interfaces.
2+
# Used as fallback when no matching beans are found in the DispatcherServlet context.
3+
# Not meant to be customized by application developers.
4+
5+
org.springframework.web.servlet.MyHandlerMapping=org.springframework.web.servlet.mvc.method.annotation.MyRequestMappingHandlerMapping
6+
7+
org.springframework.web.servlet.MyHandlerAdapter=org.springframework.web.servlet.mvc.method.annotation.MyRequestMappingHandlerAdapter
8+
9+
org.springframework.web.servlet.MyViewResolver=org.springframework.web.servlet.view.MyInternalResourceViewResolver
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.springframework.web.servlet;
2+
3+
import javax.servlet.http.HttpServletRequest;
4+
import javax.servlet.http.HttpServletResponse;
5+
6+
/**
7+
* TODO...
8+
*
9+
* @author zwd
10+
* @since 2019-04-28
11+
**/
12+
public interface MyAsyncHandlerInterceptor extends MyHandlerInterceptor{
13+
14+
default void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response,
15+
Object handler) throws Exception {
16+
}
17+
}

0 commit comments

Comments
 (0)