我有以下方法:
@RequestMapping(value = "/resource/{resourceId}", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public @ResponseBody
ResourceDto getChannelById(@PathVariable Long resourceId, QueryParameters queryParameters) {
...
}
我可以这样称呼:
GET localhost:8080 / someName / resources / 1?attr1 = 1
attr1在QueryParameters对象中正确绑定。
我想知道何时使用未知属性进行调用(QueryParameters类中不存在属性):
GET localhost:8080 / someName / resources / 1?attr1 = 1& attrUnknown = 2
并抛出错误。是否可以识别对象中不存在的属性?
编辑: QueryParameters的相关部分
private List expand = new ArrayList<>(); getter and setters ...