- Mastering Microservices with Java 9(Second Edition)
- Sourabh Sharma
- 171字
- 2021-07-02 21:54:45
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 method pow() 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 required parameter 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/" }
- 大學計算機基礎(第三版)
- AngularJS Web Application Development Blueprints
- ASP.NET動態(tài)網(wǎng)頁設計教程(第三版)
- HTML5+CSS3網(wǎng)站設計教程
- 深度強化學習算法與實踐:基于PyTorch的實現(xiàn)
- Unity Game Development Scripting
- 學習正則表達式
- QGIS Python Programming Cookbook(Second Edition)
- Kivy Cookbook
- ActionScript 3.0從入門到精通(視頻實戰(zhàn)版)
- Distributed Computing in Java 9
- Application Development with Parse using iOS SDK
- JavaScript悟道
- 從零開始學Python大數(shù)據(jù)與量化交易
- Building Web and Mobile ArcGIS Server Applications with JavaScript(Second Edition)