在Controller层方法入参使用了@RequestParam注解,但是实际请求接口时,并没有对应的参数,会报org.springframework.web.bind.MissingServletRequestParameterException: Required Long parameter 'activitiesId' is not present 异常。
eg:
@RequestMapping("hello/report")
@RestController
public class AController{
@GetMapping("/hi")
public ApiResult<Person> hello(@RequestParam(name = "activitiesId") Long activitiesId)
{
// todo
}
}
在实际请求时 hello/report/hi后面没有任何参数,此时会报MissingServletRequestParameterException异常。
注意:如果不是必填参数,可以不用加@RequestParam注解