In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of how to set the default value of receiving parameters in controller, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this controller article on how to set the default value of receiving parameters, let's take a look.
Controller sets the default value for receiving parameters, public @ ResponseBody Object queryActivityForPageByCondition (@ RequestParam (value= "kkk" required = false,defaultValue = "1") int pageNo, @ RequestParam (required = false,defaultValue = "10") int pageSize) {@ RequestParam represents the request parameter comment
Value: represents the kkk of the parameter name we passed, and the pageNo we use to receive it. As long as the parameter passed by the browser is pageNo, we don't have to write the property value.
Required=false, which represents this parameter may not be passed.
DefaultValue: represents the default value we set for this parameter.
Int: represents the type of parameter.
The problem of passing parameters of controller Mapping of controller
Implemented by annotations
@ Controller@RequestMapping (value = "/ biz/assay/assay_order_audit_condition")
Method of request
It is also achieved through annotations
GET request
RequestMapping (value = {"create"}, method = {RequestMethod.GET})
POST request
RequestMapping (value = {"create"}, method = {RequestMethod.POST})
GET request, or POST request
@ RequestMapping (value = {"batch/delete"}, method = {RequestMethod.GET, RequestMethod.POST})
Value, method name
Method, the way to request
Transmission of parameters
Write the type directly with the parameter name public String view (String Id) {} Request.getParameter method public String view () {request.getParameter ("id");} @ RequestParam annotation public String updateRecordStatusBatch (@ RequestParam (value = "ids", required = false) String [] ids) {}
Value, parameter name
Required. Whether it is required. Default is true, which means that there must be corresponding parameters in the request.
DefaultValue, the default value, if there is no parameter with the same name in the request
At this point, the parameter fieldId must be passed. If not, an error will be reported.
Must be passed on
@ RequestParam (value = "id", required = true) String id
You don't have to pass.
@ RequestParam (value = "id", required = false) String id@PathVariable Note @ RequestMapping (value = {"{id} / delete"}, method = {RequestMethod.GET}) public String showDeleteForm (@ PathVariable ("id") String Id, Model model) {}
Bind URI template variable value
Used to obtain the dynamic parameters in the request url
Used to map the template variables in the request URL to the parameters of the function processing method
A relationship between url and method needs to be configured
@ RequestMapping (value = {"{id} / delete"}, method = {RequestMethod.GET}) this is the end of the article on "how to set default values for receiving parameters in controller". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to set the default value of receiving parameters in controller". If you want to learn more, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.