官术网_书友最值得收藏!

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/" 
} 
主站蜘蛛池模板: 大洼县| 英超| 名山县| 页游| 刚察县| 聂拉木县| 鹤峰县| 信阳市| 岳西县| 原平市| 恩施市| 龙游县| 湖南省| 奇台县| 竹山县| 图们市| 岚皋县| 海盐县| 泾阳县| 响水县| 福贡县| 林西县| 唐河县| 贡觉县| 永登县| 屯门区| 舒兰市| 吉木萨尔县| 资兴市| 县级市| 达孜县| 布尔津县| 河南省| 蓬莱市| 禹城市| 武城县| 夏邑县| 鲁山县| 石城县| 陈巴尔虎旗| 霞浦县|