拓展:
ssm : Mybatis+Spring+SpringMVC
MVC三层架构
MVVM: M V VM(ViewModel: 双向绑定)
SpringMVC + Vue + SpringBoot + SpringCloud + Linux
SpringMVC执行流程( 重点)
实体类:
pojo,dto ;jojo,dio
vo:简化版实体类。比如登录只需要取用户名密码,就封装一个两个字段的实体类。
面试题: 你的项目的结构, 是设计好的, 还是演进的 ?
- 答: 演进的、All in one–>微服务
MVC框架:
①jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/hello" method="get">
<input type="text" name="method" value="delete">
<input type="submit">
</form>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
${msg}
</body>
</html>
②service
省略
③servlet
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//1.获取前端参数
String method = req.getParameter("method");
if (method.equals("add")) {
req.getSession().setAttribute("msg", "执行了add方法");
}
if (method.equals("delete")) {
req.getSession().setAttribute("msg", "执行了delete方法");
}
//2.调用业务层
//3.视图转发(请求转发)
req.getRequestDispatcher("WEB-INF/jsp/test.jsp").forward(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}
}
MVC简介
MVC框架要做哪些事情
1.将url映射到java类或java类的方法。
2.封装用户提交的数据
3.处理请求–调用相关的业务处理–封装响应数据,
4.将响应的数据进行渲染.jsp / html等表示层数据。
说明:
常见的服务器端MVC框架有: Struts、 Spring MVC、ASP.NET MVC、Zend Framework、JSF;
常见前端MVC框架: vue、 angularjs、react、backbone;
由MVC演化出了另外一些模式, 如: MVP、MVVM等等…