Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Format of @ Controller and @ RestController and @ GetMapping and @ PostMapping receive parameters in java

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the format of @ Controller and @ RestController and @ GetMapping and @ PostMapping receiving parameters in java. The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the format of @ Controller and @ RestController and @ GetMapping and @ PostMapping receiving parameters in java.

One, one. Using the @ Controller annotation, the view parser can parse the jsp,html page of return and jump to the corresponding page on the corresponding method

If you return json and other content to the page, you need to add @ ResponseBody annotation.

2.@RestController annotations are equivalent to the combination of @ Controller+@ResponseBody annotations. To return json data, you do not need to add @ ResponseBody annotations in front of the method, but using @ RestController annotations, you cannot return jsp,html pages, and the view parser cannot parse jsp,html pages.

II.

1. @ RequestMapping default method is supported by get,post.

2. @ RequestMapping (value = "createPickOrder.do", produces = "application/json;charset=utf-8", method = RequestMethod.POST)

Produces = "application/json;charset=utf-8": indicates the format of returned data

Method = RequestMethod.POST indicates the request format

Post request, if it is in json format (the transmission parameter is required to be json (application/json;charset=utf-8), the receiving parameter is either a parameter or an object and the parameter is preceded by @ RequestBody annotation); if it is a form submission (application/x-www-form-urlencoded), the receiving parameter can be either an object or multiple parameters.

Get request. Parameters cannot be in json (application/json;charset=utf-8) format, but can only be in form (application/x-www-form-urlencoded) format.

3 、

@ PostMapping

Map a POST request

New features of Spring MVC

Provides support for Restful style

@ GetMapping to process get requests

@ PostMapping to process post requests

@ PutMapping to process put requests

@ DeleteMapping to process delete requests

@ PostMapping (value = "/ user/login")

Equivalent to

@ RequestMapping (value = "/ user/login", method = RequestMethod.POST)

Click to enter

Thank you for your reading. The above is the content of @ Controller and @ RestController and @ GetMapping and @ PostMapping receiving parameter formats in java. After the study of this article, I believe you have a deeper understanding of the format of @ Controller and @ RestController and @ GetMapping and @ PostMapping receiving parameters in java, and the specific usage still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report