SpringMVC (4) domain object shared data

pageContext: represents the scope of the jsp page HttpServletRequest: represents the scope of a request HttpSession: represents the scope of a session ServletContext: represents the scope of the entire application 1. Share data to the requesting domain: 1.1 Use ServletAPI to share data with request domain objects @RequestMapping(“testServletAPI”) public String testServletAPI(HttpServletRequest request){ request.setAttribute(“testScope”,”hello,servletAPI”); return “success”; […]

Source code analysis SpringMVC’s RequestMapping annotation principle

1. Start initialization Core: After obtaining all the beans existing in the application context, traverse them in sequence, analyze the annotation @RequestMapping that exists in each target handler & target method, and encapsulate its related attributes into an instance RequestMappingInfo. Finally, the mapping relationship between uri & handler is maintained in the internal class RequestMappingInfo […]

SpringMVC Knowledge Essay

RESTful request Concept The RESTful (Representational State Transfer) style is a software architecture style for designing Web APIs based on the HTTP protocol. It first appeared in Roy Thomas Fielding’s doctoral thesis in 2000, where it was mentioned: The purpose of my writing this article is to understand and evaluate the architectural design of network-based […]

SpringMVC gets request parameters

Article directory 1. Obtain through ServletAPI 2. Obtain the request parameters through the formal parameters of the controller method 3. @RequestParam 4. @RequestHeader 5. @CookieValue 6. Obtain request parameters through POJO 7. Solve the garbled problem of obtaining request parameters 1. Obtain through ServletAPI Use HttpServletRequest as a formal parameter of the controller method. At […]

springMVC starts!

1.DispatcherServlet DispatcherServlet is the core of springMVC. DispatcherServlet is mainly used for responsibility scheduling. It is mainly used to control the process. Its main responsibilities are as follows: File upload parsing, if the request type is multipart, file upload parsing will be performed through MultipartResolver Through HandlerMapping, the request is mapped to the processor (returns […]

SpringMVC execution process

Article directory 1. SpringMVC common components 2. DispatcherServlet initialization process a>Initialize WebApplicationContext b>Create WebApplicationContext c>DispatcherServlet initialization strategy 3. DispatcherServlet calls the component to process the request a>processRequest() b>doService() c>doDispatch() d>processDispatchResult() 4. SpringMVC execution process 1. SpringMVC common components DispatcherServlet: Front-end controller, does not require engineers to develop, provided by the framework Function: Unified processing of […]

SSM (Spring-MyBatis-SpringMVC) framework integration [full version]

Integrate SSM 01 Basic configuration file relationship web.xml configurationDispatcherServlet 02 Required maven dependencies <!–Dependencies 1.junit 2. Database connection pool 3.servlet 4.jsp 5.mybatis 6.mybatis-spring 7.spring –> <dependencies> <!–log4j–> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <!–lombok plug-in–> <!– https://mvnrepository.com/artifact/org.projectlombok/lombok –> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.10</version> </dependency> <!–Junit–> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <!–Database driver–> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.47</version> </dependency> […]

springmvc http request, supports get, post, attachment transmission and parameter transmission

Mainly solves the problem of http requests supporting conventional methods such as get, post, put, delete, etc., supporting the transmission of parameter formats such as @RequestParam, @RequestBody, @PathVariable, etc., and supporting the transmission of attachments and parameters at the same time. The main code is as follows: package mes.client.action; import cn.hutool.crypto.digest.DigestUtil; import com.alibaba.fastjson.JSON; import mes.client.pojo.po.CommonEntityPo; […]

Analysis of SpringMVC custom interceptor principle

Analysis on the principle of SpringMVC custom interceptor 1. Concept Interceptor is a mechanism that dynamically intercepts method calls. In Dynamically intercept the execution of controller methods in SpringMVC. 2. Function Execute preset code before and after calling the specified method to enhance requests and responses. Prevent execution of the original method 3. Custom interceptor […]