【发布时间】:2018-12-24 04:01:17
【问题描述】:
我正在开发一个 java springboot 项目以及其他 api,我需要在其中一个 uri 中传递参数,当我使用它时出现“不支持请求方法 GET”错误
//@GetMapping("logs/date?from={from}&to={to}")
@RequestMapping(value="logs/date?from={from}&to={to}",method=RequestMethod.Get)
public list getLogs(@RequestParam(value="from") String from,@RequestParam("to") String to)){....}
当我使用时它可以正常工作
@RequestMapping(value="logs/date/from={from}&to={to}",method=RequestMethod.Get)
public list getLogs(@PathVariable(value="from") String from,@PathVariable("to") String to)){....}
但我需要网址有“?”在传递参数之前,所以当我替换时
@RequestMapping(value="logs/date/from={from}&to={to}",method=RequestMethod.Get)
有了这个
@RequestMapping(value="logs/date?from={from}&to={to}",method=RequestMethod.Get)
我得到 GET 方法不支持错误。
【问题讨论】:
-
在未在值映射中指定参数后,我收到“没有可用于 'logs/date/2016-03-03/2016-03-30' 的消息”错误
标签: java rest spring-boot model-view-controller