- 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/" }
- Spring Boot 2實戰(zhàn)之旅
- 微服務(wù)與事件驅(qū)動架構(gòu)
- TypeScript圖形渲染實戰(zhàn):基于WebGL的3D架構(gòu)與實現(xiàn)
- Drupal 8 Configuration Management
- ASP.NET Core 2 Fundamentals
- Java Web開發(fā)詳解
- Python語言實用教程
- Node學(xué)習(xí)指南(第2版)
- HoloLens與混合現(xiàn)實開發(fā)
- .NET 4.5 Parallel Extensions Cookbook
- Fastdata Processing with Spark
- Learning Nessus for Penetration Testing
- Java EE項目應(yīng)用開發(fā)
- Hadoop Blueprints
- Puppet Cookbook(Third Edition)