我在下面向spring
控制器发出请求,但我在itemfilter
bean中变空了。
http://localhost:8080:/project/api/paytype?cacheBuster=1457063200591&itemfilter=%7B%22name%22:%22Test%22,%22sortlist%22:%5B%7B%22fieldName%22:%22name%22,%22order%22:%22desc%22%7D%5D,%22filterlist%22:%5B%7B%22fieldName%22:%22name%22,%22operator%22:%22a%22,%22value%22:%221%22%7D%5D%7D&page=0&size=20
Spring控制器方法: -
@RequestMapping(value = "/paytypes", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<List<Payintype>> getAllPaytypes(Pageable pageable, ItemFilter itemfilter) throws URISyntaxException {}
pageable正确填充,但我得到itemfilter对象为空。有人可以帮忙解决这个问题吗?
答案 0 :(得分:0)
您使用的API网址是:
http://localhost:8080:/project/api/paytype&cacheBuster=1457063200591&itemfilter=%7B%22name%22:%22Test%22,%22sortlist%22:%5B%7B%22fieldName%22:%22name%22,%22order%22:%22desc%22%7D%5D,%22filterlist%22:%5B%7B%22fieldName%22:%22name%22,%22operator%22:%22a%22,%22value%22:%221%22%7D%5D%7D&page=0&size=20
这应该是:
http://localhost:8080:/project/api/paytype?cacheBuster=1457063200591&itemfilter=%7B%22name%22:%22Test%22,%22sortlist%22:%5B%7B%22fieldName%22:%22name%22,%22order%22:%22desc%22%7D%5D,%22filterlist%22:%5B%7B%22fieldName%22:%22name%22,%22operator%22:%22a%22,%22value%22:%221%22%7D%5D%7D&page=0&size=20
你需要使用问号(?)而不是&符号(&amp;)作为url和参数之间的分隔符