【C016002】在SpringMVC中,SpringMVC使用@PathVariable 注解接收基本类型的数据,代码如下:
@RequestMapping("/{reqKey}/req.do")
@ResponseBody
public ResponseEntity<String> ordersBack(
@PathVariable String reqKey,
@RequestParam(value="intVal") int intVal,
@RequestParam(value="strVal") String strVal) throws Exception{
return new ResponseEntity("ok", HttpStatus.OK);
}
需要改动( )代码才能正常工作。
A.给@RequestParam增加required=false?属性
B.修改@RequestParam(value="intVal") int intVal 为
@RequestParam(value="intVal") Integer intVal
C.@RequestParam(value="intVal") int intVal使用defaultValue
D.@ResponseBody
删除此注释