所有!我目前正在做一个新的项目与SpringBoot
和以下是我目前遇到的问题。我想overload
这个控制器与不同类型的参数。我该如何实现呢?
@RequestMapping(method = RequestMethod.POST, value = "/register")
public Status registerConnection(@RequestBody Connection connection) throws Exception
{
xxxx
}
@RequestMapping(method = RequestMethod.POST, value = "/register")
public Status registerConnections(@RequestBody List<Connection> connections){
xxxx
}
目前,如果我运行该程序,它报告了一个错误,如下所示:
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'connectionController' method
com.comacnet.controller.ConnectionController#registerConnections(List)
to {POST [/connection/register]}: There is already 'connectionController' bean method
com.comacnet.controller.ConnectionController#registerConnection(Connection) mappe
1条答案
按热度按时间bvn4nwqk1#
应该为Map使用不同路径。
但是,如果你仍然希望做同样的下面的代码片段可能会有所帮助.