mvc 是一款简化版本的 spring mvc 框架,主要用于 mvc 原理的学习。
-
JDK 1.7
-
Maven 3.x+
$ git clone https://github.com/houbb/mvc.git
- 编译
$ mvc clean install
- 运行
mvc-test 模块,使用 tomcat 插件运行
http://localhost:8081/index/echo?param=1
页面返回
Echo :1
<dependency>
<groupId>com.github.houbb</groupId>
<artifactId>mvc-core</artifactId>
<version>0.0.2</version>
</dependency>
和 spring mvc 类似
import com.github.houbb.mvc.annotation.Controller;
import com.github.houbb.mvc.annotation.RequestMapping;
import com.github.houbb.mvc.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Controller
@RequestMapping("/index")
public class IndexController {
@RequestMapping("/print")
public void print(@RequestParam("param") String param) {
System.out.println(param);
}
@RequestMapping("/echo")
public void echo(HttpServletRequest request,
HttpServletResponse response,
@RequestParam("param") String param) {
try {
response.getWriter().write("Echo :" + param);
} catch (IOException e) {
e.printStackTrace();
}
}
}
-
全覆盖 spring-mvc 特性
-
IOC 与 MVC 整合
Java Servlet 教程-20-自己手写实现 spring mvc 整体思路
Java Servlet 教程-21-自己手写 spring mvc 简单实现
mvc-01-Model-View-Controller 概览
web mvc-05-JSF JavaServer Faces