Home Java javaTutorial SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

Mar 03, 2017 am 10:49 AM
springmvc

In series (SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action) we showed a simple get request and returned a simple helloworld page. In this article, we will learn how to configure the URL mapping rules of an action.

In series (SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action) we configured a @RequestMapping(value = "/helloworld") on HelloWorldController, which means that all action requests to the controller must start with "/helloworld".

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.URL path mapping

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.Configure multiple URL mappings for one action:

We put @ in the index() action method of HelloWorldController in the previous article RequestMapping is changed to @RequestMapping(value={"/index", "/hello"}, method = {RequestMethod.GET}), which means that the action is configured with two mappings of /index and /hello. Run the test as follows:

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action

#You can see that the /helloworld/hello request is also successfully matched.

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action. URL request parameter mapping:

This is often used when querying, for example, we obtain a certain record based on id or number.

Add a getDetail action in HelloWorldController, the code is as follows:

@RequestMapping(value="/detail/{id}", method = {RequestMethod.GET})public ModelAndView getDetail(@PathVariable(value="id") Integer id){
    
    ModelAndView modelAndView = new ModelAndView();  
    modelAndView.addObject("id", id);  
    modelAndView.setViewName("detail");  
    return modelAndView;
}
Copy after login


where value="/detail/{id}", {id} in It is a placeholder indicating that the URL requested as /detail/xxxx can be mapped, such as: /detail/SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (3) Mapping Rules from URL Request to Action, etc.

Method parameter @PathVariable(value="id") Integer id is used to map the variable corresponding to the placeholder in the URL to the parameter id, the value of value in @PathVariable(value="id") Must be consistent with the value in the placeholder /{id} braces.

Add the detail.jsp view in views to display the obtained id value. The view content is as follows:

<%@ page language="java" contentType="text/html; charset=UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"
    pageEncoding="UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"%><!DOCTYPE html PUBLIC "-//WSpringMVC Learning Series (3) Mapping Rules from URL Request to ActionC//DTD HTML SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.0SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action Transitional//EN" "http://www.wSpringMVC Learning Series (3) Mapping Rules from URL Request to Action.org/TR/htmlSpringMVC Learning Series (3) Mapping Rules from URL Request to Action/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"><title>Insert title here</title></head><body>
    ${id}</body></html>
Copy after login


Run the test, Request URL addresshttp://localhost:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/detail/SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (3) Mapping Rules from URL Request to Action, the results are as follows :

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action

You can see that the id we requested has been correctly displayed.

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.URL wildcard mapping:

We can also configure URL mapping through wildcard characters. The wildcard characters include "?" and "*". Among them, "?" means SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action character, "*" means matching multiple characters, and "**" means matching 0 or more paths.

For example:

"/helloworld/index?" can match "/helloworld/indexA" and "/helloworld/indexB", but cannot match "/helloworld/index" nor " /helloworld/indexAA";

"/helloworld/index*" can match "/helloworld/index", "/helloworld/indexA", "/helloworld/indexAA" but not "/helloworld/index/ A";

"/helloworld/index/*" can match "/helloworld/index/", "/helloworld/index/A", "/helloworld/index/AA", "/helloworld/index" /AB" but cannot match "/helloworld/index", "/helloworld/index/A/B";

"/helloworld/index/**" can match "/helloworld/index/" There are many sub-paths, such as: "/helloworld/index/A/B/C/D";

If there are now "/helloworld/index" and "/helloworld/*", if the request address is " /helloworld/index" So how will it match? Spring MVC will match based on the longest match first principle (that is, which one matches the most in the mapping configuration), so it will match "/helloworld/index". Let's do the test below:

Add a urlTest in HelloWorldController action, the content is as follows:

@RequestMapping(value="/*", method = {RequestMethod.GET})public ModelAndView urlTest(){
    
    ModelAndView modelAndView = new ModelAndView();   
    modelAndView.setViewName("urltest");  
    return modelAndView;
}
Copy after login


Add a new view urltest.jsp in the views folder. In order to distinguish it from index.jsp, the content of urltest.jsp is as follows:

<%@ page language="java" contentType="text/html; charset=UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"
    pageEncoding="UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"%><!DOCTYPE html PUBLIC "-//WSpringMVC Learning Series (3) Mapping Rules from URL Request to ActionC//DTD HTML SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.0SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action Transitional//EN" 
    "http://www.wSpringMVC Learning Series (3) Mapping Rules from URL Request to Action.org/TR/htmlSpringMVC Learning Series (3) Mapping Rules from URL Request to Action/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action">
    <title>Insert title here</title>
    </head>
    <body>
    urlTest!</body></html>
Copy after login


Request http://localhost:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/index to view the results:

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

You can see the mapping is the action corresponding to index.

Request http://localhost:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/AAA to view the results:

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

It can be seen that the action corresponding to urlTest is mapped.

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.URL regular expression mapping:

Spring MVC还支持正则表达式方式的映射配置,我们通过一个测试来展示:

在HelloWorldController添加一个regUrlTest的action,内容如下:

@RequestMapping(value="/reg/{name:\\w+}-{age:\\d+}", 
method = {RequestMethod.GET})public ModelAndView regUrlTest(@PathVariable(value="name") String name, 
@PathVariable(value="age") Integer age){
    
    ModelAndView modelAndView = new ModelAndView();   
    modelAndView.addObject("name", name); 
    modelAndView.addObject("age", age); 
    modelAndView.setViewName("regurltest");  
    return modelAndView;
}
Copy after login


在views文件夹中新加一个视图regurltest.jsp内容如下:

<%@ page language="java" contentType="text/html; charset=UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"
    pageEncoding="UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"%><!DOCTYPE html PUBLIC "-//WSpringMVC Learning Series (3) Mapping Rules from URL Request to ActionC//DTD HTML SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.0SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action Transitional//EN" 
    "http://www.wSpringMVC Learning Series (3) Mapping Rules from URL Request to Action.org/TR/htmlSpringMVC Learning Series (3) Mapping Rules from URL Request to Action/loose.dtd"><html>
    <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action">
    <title>Insert title here</title></head><body>
    ${name}-${age}</body></html>
Copy after login


请求http://www.php.cn/:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/reg/Hanmeimei-SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (3) Mapping Rules from URL Request to Action查看结果:

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

请求http://www.php.cn/:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/reg/Hanmeimei-Lilei查看结果(会发现找不到对应的action返回SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action):

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.限制action所接受的请求方式(get或post):

之前我们在HelloWorldController的index() action方法上配置的为@RequestMapping(value="/*", method = {RequestMethod.GET})我们把它改为@RequestMapping(value="/*", method = {RequestMethod.POST})再次请求http://www.php.cn/:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/index试一下:

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

这里可以看到结果映射到了urlTest这个action,这是因为我们在urlTest上配置的为@RequestMapping(value="/*", method = {RequestMethod.GET}),当index这个action映射不在符合时便映射到了urlTest。

我们也可以这样配置@RequestMapping(value="/*", method = {RequestMethod.GET, RequestMethod.POST})表示该action可以接受get或post请求,不过更简单的是不对method做配置则默认支持所有请求方式。

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.限制action所接受请求的参数:

我们可以为某个action指定映射的请求中必须包含某参数,或必须不包含某参数,或者某参数必须等于某个值,或者某参数必须不等于某个值这些限制。

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.指定映射请求必须包含某参数:

在HelloWorldController添加一个paramsTest的action,内容如下:

@RequestMapping(value="/paramstest", params="example", 
method = {RequestMethod.GET})public ModelAndView paramsTest(){
    
    ModelAndView modelAndView = new ModelAndView();   
    modelAndView.setViewName("paramstest");  
    return modelAndView;
}
Copy after login


在views文件夹中新加一个视图paramstest.jsp内容如下:

<%@ page language="java" contentType="text/html; charset=UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"
    pageEncoding="UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"%><!DOCTYPE html PUBLIC "-//WSpringMVC Learning Series (3) Mapping Rules from URL Request to ActionC//DTD HTML SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.0SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action Transitional//EN" 
    "http://www.wSpringMVC Learning Series (3) Mapping Rules from URL Request to Action.org/TR/htmlSpringMVC Learning Series (3) Mapping Rules from URL Request to Action/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; 
    charset=UTF-SpringMVC Learning Series (3) Mapping Rules from URL Request to Action"><title>Insert title here</title></head><body>
    paramstest!</body></html>
Copy after login


请求http://www.php.cn/:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/paramstest查看结果:

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

这里可以看到没有找到paramsTest这个action结果还是映射到了urlTest这个action。

请求http://www.php.cn/:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/paramstest?example查看结果:

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action

这次可以看到请求映射到了paramsTest这个action。

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action.指定映射请求必须包含某参数:

把刚才添加的paramsTest的@RequestMapping(value="/paramstest", params="example", method = {RequestMethod.GET}) 改为@RequestMapping(value="/paramstest", params="!example", method = {RequestMethod.GET})

重新请求http://www.php.cn/:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/paramstest?example查看结果:

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action0

可以看到又没有找到paramsTest这个action而映射到了urlTest这个action。

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.指定映射请求中或者某参数必须等于某个值:

把刚才添加的paramsTest的@RequestMapping(value="/paramstest", params="example", method = {RequestMethod.GET}) 改为@RequestMapping(value="/paramstest", params="example=AAA", method = {RequestMethod.GET})

Request http://www.php.cn/:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/paramstest?example=BBB View results:

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action

You can see that paramsTest was not found This action is mapped to the urlTest action.

Request http://localhost:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/paramstest?example=BBB View the results:

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action

This time you can see that the request is mapped to paramsTest this action.

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.SpringMVC Learning Series (3) Mapping Rules from URL Request to Action. Specify that a certain parameter in the mapping request must not be equal to a certain value:

Change the @RequestMapping(value="/paramstest", of the paramsTest you just added, params="example", method = {RequestMethod.GET}) changed to @RequestMapping(value="/paramstest", params="example!=AAA", method = {RequestMethod.GET})

Request http://localhost:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/paramstest?example=AAA View the results:

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (3) Mapping Rules from URL Request to Action

You can see The request is mapped to the action paramsTest.

Request http://localhost:SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0SpringMVC Learning Series (3) Mapping Rules from URL Request to Action0/SpringMVCLesson/helloworld/paramstest?example=AAA View the results:

SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to ActionSpringMVC Learning Series (3) Mapping Rules from URL Request to Action

##You can see that the paramsTest action was not found And it is mapped to the action urlTest.

Note: When we specify multiple parameters for params, such as: params={"exampleSpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action", "exampleSpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action"}, it represents an and relationship, that is, the two parameter restrictions must be met at the same time.

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action. Limit the request header parameters accepted by action:

Same as limiting the request parameters accepted by action, we can also specify mapping for an action The request header must contain a certain parameter, or must not contain a certain parameter, or a certain parameter must be equal to a certain value, or a certain parameter must not be equal to a certain value.

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action. Specify that the mapping request header must contain certain parameters:

@RequestMapping(value="/headerTest", headers = "example"). It is the same as limiting request parameters. You can refer to the above example for testing.

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.SpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action. The specified mapping request header must

not contain certain parameters:

@RequestMapping(value="/headerTest", headers = "!example"). It is the same as limiting request parameters. You can refer to the above example for testing.

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.SpringMVC Learning Series (3) Mapping Rules from URL Request to Action. Specify that a certain parameter in the mapping request header must be equal to a certain value:

@RequestMapping(value="/headerTest", headers = "Accept=text/html"). It is the same as limiting request parameters. You can refer to the above example for testing.

SpringMVC Learning Series (3) Mapping Rules from URL Request to Action.SpringMVC Learning Series (3) Mapping Rules from URL Request to Action. Specify that a certain parameter in the mapping request header must

not be equal to a certain value:

@RequestMapping(value="/headerTest", headers = "Accept! =text/html"). It is the same as limiting request parameters. You can refer to the above example for testing.

Note: When we specify multiple parameters for headers, such as: headers={"exampleSpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action", "exampleSpringMVC Learning Series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action) Mapping Rules from URL Request to Action"}, it represents an and relationship, that is, the two parameter restrictions must be met at the same time.

The above is the content of the mapping rules from URL request to Action in SpringMVC learning series (SpringMVC Learning Series (3) Mapping Rules from URL Request to Action), more related content Please pay attention to the PHP Chinese website (www.php.cn)!



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Comparison and difference analysis between SpringBoot and SpringMVC Comparison and difference analysis between SpringBoot and SpringMVC Dec 29, 2023 am 11:02 AM

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 are the differences between SpringBoot and SpringMVC? What are the differences between SpringBoot and SpringMVC? Dec 29, 2023 am 10:46 AM

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

What is the difference between SpringBoot and SpringMVC? What is the difference between SpringBoot and SpringMVC? Dec 29, 2023 pm 05:19 PM

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

What are the differences between springboot and springmvc What are the differences between springboot and springmvc Jun 07, 2023 am 10:10 AM

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.

What are the differences between spring and springmvc What are the differences between spring and springmvc Dec 29, 2023 pm 05:02 PM

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.

How to use Java's SpringMVC interceptor How to use Java's SpringMVC interceptor May 13, 2023 pm 02:55 PM

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

Using SpringMVC for Web service processing in Java API development Using SpringMVC for Web service processing in Java API development Jun 17, 2023 pm 11:38 PM

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

Compare the similarities and differences between SpringBoot and SpringMVC Compare the similarities and differences between SpringBoot and SpringMVC Dec 29, 2023 am 08:30 AM

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

See all articles