0
     @RequestMapping(value = "/states/{countrycode}", method = 
RequestMethod.GET )
    public Service getStates(@PathVariable ("countrycode") String 
countrycode,@RequestParam(value = "count", required = false, defaultValue = 
"10") Integer count)

在这种情况下,我的问题是我不想将默认值设置为某个计数,

如果用户将通过计数,那么它应该返回那么多记录并且它正在返回,但是当用户没有通过任何计数时,它应该从数据库返回所有记录,但它不起作用这是我的服务返回逻辑return modelststelist.subList(0, count);,这里计数即将到来从方法作为我的服务中的参数。

4

1 回答 1

4

在你的情况下,删除 required = false, defaultValue = "10"

像这样添加,

public Service getStates(@PathVariable ("countrycode") String 
countrycode,@RequestParam(value = "count") Integer count)

将计数传递给后端,获取详细信息并返回

于 2015-06-01T06:24:23.820 回答