Spring MVC for beginners 笔记

近期开始学习 Spring MVC, 在 Udemy 上找到一门入门级课程,做一个 Todo List Management Application。将学习过程记录一下,增强对基本概念的理解。

Servlet 是什么?

A Java programming language class used to extend the capabilities of servers that host applications accessed by means of a request-response programming model.

Any servlet should extends HttpServlet. (LoginServlet extends HttpServlet)

  • @WebServlet(urlPatterns = "/login.do")
  • Override the doGet method to let HttpServlet make response to the content requested.

JSP 是什么?

A collection of teechnologies that helps developers create dynamic web pages based on HTML, XML or some other formats.

Spring MVC Arcitecture

先通过 Front Controller, 即 servlet, 确定向哪个 Controller 传递请求,如 Login Controller,controller 收到请求后,找到对应的地址如 “/login”。Controller 将响应传递回 Front Controller, 随后 front controller 去 view 里面寻找相应的前端模板。再返回这个模板内容,就可以在网页上看到了。

Spring MVC for beginners 笔记

Java Web Application Architecture

  • MVC Architecture
    • Model - Todo.java - Session or request attributes
    • View - Todo.jsp file - Take the data from the model and show them to the screen
    • Controller - LoginServlet.java - Get the data from database and populate it to the model.
    • Front Controller (In Spring MVC) - DispatcherServlet ???
      • Easy to control - Directly modify login, todo pattern...
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!