- 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/" }
- iOS Game Programming Cookbook
- Python自然語言處理實戰:核心技術與算法
- OpenShift開發指南(原書第2版)
- Go語言高效編程:原理、可觀測性與優化
- 深入淺出RxJS
- 正則表達式經典實例(第2版)
- 后臺開發:核心技術與應用實踐
- Hacking Android
- 基于GPU加速的計算機視覺編程:使用OpenCV和CUDA實時處理復雜圖像數據
- 計算機應用基礎案例教程(第二版)
- 高質量程序設計指南:C++/C語言
- Python數據可視化之matplotlib實踐
- 輕松學Scratch 3.0 少兒編程(全彩)
- Python AI游戲編程入門:基于Pygame和PyTorch
- Getting Started with Hazelcast