- Mastering Microservices with Java
- Sourabh Sharma
- 172字
- 2021-07-02 13:03:32
The @RequestParam annotation
@RequestParam is responsible for binding the query parameter to the parameter of the controller's method. For example, the QueryParam base and exponent are bound to parameters b and e of the pow() method of CalculationController, respectively. Both of the query parameters of the pow() method are required, since we are not using any default value for them. Default values for query parameters could be set using the defaultValue property of @RequestParam, for example, @RequestParam(value="base", defaultValue="2"). Here, if the user does not pass the query parameter base, then the default value 2 would be used for the base.
If no defaultValue is defined, and the user doesn't provide the request parameter, then RestController returns the HTTP status code 400 with the message Required String parameter 'base' is not present. It always uses the reference of the first parameter required if more than one of the request parameters is missing:
{ "timestamp": 1464678493402, "status": 400, "error": "Bad Request", "exception": "org.springframework.web.bind.MissingServletRequestParameterException", "message": "Required String parameter 'base' is not present", "path": "/calculation/power/" }
- 深入核心的敏捷開發:ThoughtWorks五大關鍵實踐
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- INSTANT FreeMarker Starter
- 劍指JVM:虛擬機實踐與性能調優
- Java入門很輕松(微課超值版)
- Mastering Entity Framework
- Animate CC二維動畫設計與制作(微課版)
- Salesforce Reporting and Dashboards
- 深入分布式緩存:從原理到實踐
- Test-Driven Machine Learning
- App Inventor創意趣味編程進階
- Visual Basic 6.0程序設計實驗教程
- 細說Python編程:從入門到科學計算
- Beginning C++ Game Programming
- RubyMotion iOS Develoment Essentials