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)!

Start Spring using IntelliJIDEAUltimate version...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Java...

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to set the SpringBoot project default run configuration list in Idea using IntelliJ...


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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools