我实现了一个简单的rest GET服务,并且想修改该服务的ulr。
现在的网址是:http://localhost:8011/types/id?date=2019-07-30T11:35:42
我想添加一个过滤器并在日期中添加一些括号[],
像这样:http://localhost:8011/types/id?filter [date] = 2019-07-30T11:35:42
这是我的Get服务,在值中我具有“ types / id”,但我不知道如何为请求的参数添加过滤器和括号。
@RequestMapping(value = "types/id", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<?> getTicketids( @RequestParam(required = false) String date)
{
...
}
我对我可以更改或应阅读的内容提出的建议将不胜感激。
最佳答案
我假设您正在使用Spring定义RestController。通常,参数应该像这样工作:
public ResponseEntity<?> getTicketids( @RequestParam(name = "filterDate", required = false) String date)
{
...
}
此代码允许请求http://localhost:8011/types/id?filterDate=mydate
但是,方括号是not allowed in an URL,因此您可能需要重新考虑该特定方法。
关于java - 在其余服务中修改GET的网址路径,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58837790/