SpringMVC Learning Series (1) First introduction to SpringMVC
1. Foreword:
My acquaintance with SpringMVC stems from the fact that I wanted to build a WeChat public account management platform for fun. Since I want to do this, I need to consider the choice of platform. Because my friend only has a virtual host running a Linux system, and some of his own forums are also running on it. The Windows virtual host cannot be found, and it certainly cannot be changed to a system hosted by a friend. At the beginning, I planned to use mono to run the framework of the previous .Net MVC project to see if it could be used, but found that it could not run at all (the project used Spring.NET at that time, mono and Spring.NET were not compatible, and Sping.NET The forum said it was due to a problem with mono's reflection implementation mechanism. The good news is that the latest Spring.NET project already supports mono. Although the official website says there are still some bugs, this is much better than before when it couldn't run at all. I believe it will be in the future. It will get better and better. See SPRING-NET-MONO for details, you may need FQ, you know...).
So I decided to use Java for development. The first thing I started to read was some information on the classic SSH framework. I even bought a book for reference, but I started to have questions after not reading much. Let me The most unacceptable thing is Struts2's approach of one action per class (someone in the comments has already pointed out that Struts2 can also implement multiple Action methods, thank you very much for your correction).
According to this method, four classes are needed to implement the basic CURD operation of an object, and a Java class can only belong to one class file. In this way, a project will generate a bunch of class files just by action. Moreover, there is only one action in the file and there is not much content. It is too verbose and I feel that the development efficiency is very low (the above feelings are only my feelings when I saw struts2 at the time. Please criticize and correct me if there is anything wrong), so I decided to change to other methods. I just happened to see the introduction of Spring MVC of Spring 3, the annotation-based controller, and the action declaration method are very similar to .Net MVC, and I immediately decided to adopt it, so this series of articles was born.
Convention:
The Spring version used in this series is:
spring-framework-3.2.5.RELEASE, and the Hibernate version is hibernate-release-4.2.8.Final , using the combination of Spring+Hibernate+Spring MVC.
2. What is Spring MVC:
Spring MVC is a follow-up product of SpringFrameWork. It provides a full-featured MVC module for building Web applications, and Struts2 is also an excellent MVC framework. The difference is that the introduction of annotated controllers in Spring 2.5 and its continuous improvement since Spring 3 have made the development structure using the Spring MVC framework clear and clear, and the efficiency has been greatly improved.
3. Annotated Spring MVC response process: Drawing 1 4. Simple description of important interfaces and classes:
DispatcherServlet: Front-end controller, used to receive requests.
HandlerMapping interface: Mapping used to handle requests.
DefaultAnnotationHandlerMapping: Implementation of the HandlerMapping interface, used to map a URL to a specific Controller class.
HandlerAdapter interface: Mapping used to handle requests.
AnnotationMethodHandlerAdapter: A sample of the HandlerAdapter interface, used to map a URL to a method of the corresponding Controller class.
ViewResolver interface: used to parse View.
InternalResourceViewResolver: Implementation of the ViewResolver interface, used to resolve the logical view name of ModelAndView into a specific View.
The above is the first introduction to SpringMVC in the SpringMVC learning series (1). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



SpringBoot and SpringMVC are both commonly used frameworks in Java development, but there are some obvious differences between them. This article will explore the features and uses of these two frameworks and compare their differences. First, let's learn about SpringBoot. SpringBoot was developed by the Pivotal team to simplify the creation and deployment of applications based on the Spring framework. It provides a fast, lightweight way to build stand-alone, executable

What is the difference between SpringBoot and SpringMVC? SpringBoot and SpringMVC are two very popular Java development frameworks for building web applications. Although they are often used separately, the differences between them are obvious. First of all, SpringBoot can be regarded as an extension or enhanced version of the Spring framework. It is designed to simplify the initialization and configuration process of Spring applications to help developers

SpringBoot and SpringMVC are two frameworks commonly used in Java development. They are both provided by the Spring framework, but they have some differences in functions and usage methods. This article will introduce the characteristics and differences of SpringBoot and SpringMVC respectively. 1. Features of SpringBoot: Simplified configuration: SpringBoot greatly simplifies the project configuration process through the principle of convention over configuration. It can automatically configure the parameters required by the project, and developers

The difference between spring and springmvc: 1. Positioning and functions; 2. Core functions; 3. Application areas; 4. Extensibility. Detailed introduction: 1. Positioning and functions. Spring is a comprehensive application development framework that provides dependency injection, aspect-oriented programming, transaction management and other functions. It is designed to simplify the development of enterprise-level applications, and Spring MVC is the Spring framework. A module in it is used for the development of Web applications and implements the MVC pattern; 2. Core functions and so on.

The differences between springboot and springmvc are: 1. Different meanings; 2. Different configurations; 3. Different dependencies; 4. Different development times; 5. Different productivity; 6. Different ways to implement JAR packaging function; 7. Whether batch processing is provided Function; 8. Different functions; 9. Different community and documentation support; 10. Whether deployment descriptors are required.

With the development of the Internet, Web services are becoming more and more common. As an application programming interface, JavaAPI is constantly launching new versions to adapt to different application scenarios. As a popular open source framework, SpringMVC can help us easily build web applications. This article will explain in detail how to use SpringMVC for Web service processing in JavaAPI development, including configuring SpringMVC, writing controllers, and using

The role of interceptor SpringMVC's interceptor is similar to the filter in Servlet development, which is used to pre-process and post-process the processor. Interceptors are connected into a chain in a certain order, and this chain is called an interceptor chain (InterceptorChain). When an intercepted method or field is accessed, the interceptors in the interceptor chain will be called in the order they were previously defined. Interceptors are also the specific implementation of AOP ideas. The difference between interceptors and filters: Filter (Filter) The scope of use of interceptor (Intercepter) is part of the servlet specification and can be used by any JavaWeb project. Spri

Analyzing the similarities and differences between SpringBoot and SpringMVC SpringBoot and SpringMVC are very important development frameworks in the Java field. Although they are both part of the Spring framework, there are some obvious differences in usage and functionality. This article will compare SpringBoot and SpringMVC and analyze the similarities and differences between them. First, let's learn about SpringBoot. SpringBo
