无法使用不同的参数创建两个REST方法

时间:2014-04-07 09:13:06

标签: rest spring-mvc controller

我试图创建两个名称相同但参数不同的方法,但我收到错误:

  

线程“main”中的异常   org.springframework.beans.factory.BeanCreationException:错误   创建名为'requestMappingHandlerMapping'的bean   类路径资源   [组织/ springframework的/网络/ servlet的/配置/注解/ DelegatingWebMvcConfiguration.class]:   调用init方法失败;嵌套异常是   java.lang.IllegalStateException:找到不明确的映射。

以下是两种方法:

@RequestMapping(value = "/rest/hikes",
        method = RequestMethod.POST,
        produces = "application/json")
@Timed
public void create(@RequestBody HikeDto hikedto) {...}

@RequestMapping(value = "/rest/hikes",
        method = RequestMethod.POST,
        produces = "application/json")
@Timed
public void create(@RequestBody HikeDto hikedto, ArrayList<HikeDto> hikes) {...}

我想做的是什么?

谢谢。

0 个答案:

没有答案