java - url的@PathVariable Map语法?

标签 java spring spring-restcontroller request-mapping

我有一个看起来像这样的 Controller

@RequestMapping(value = "/start/{params}", method = GET, produces = { APPLICATION_JSON_VALUE, APPLICATION_XML_VALUE })
String doStart(@PathVariable("params") Map<String,String> startParams)

如何从 url 发送 startParams

我所有的尝试都以:

结束

IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.util.Map]: no matching editors or conversion strategy found

也不能发送空的like

theurl/start/

它给了

dec 18, 2015 10:56:07 FM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI

是否有可能不发送任何参数,或者我需要一个单独的方法吗?:

最佳答案

您必须使用 @MatrixVariable 而不是 @PathVariable

看看这个例子Spring Matrix variable usage

关于java - url的@PathVariable Map语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34352870/

相关文章:

java - 无法从 Oracle 调用 dll

java - Spring + Hibernate 中出现 "Closed connection"问题

java - 在 Spring 框架中使用抽象工厂

java - 休息 Controller 工作,但 ajax post 方法返回错误

java - Spring 存储库并不总是抛出 DataIntegrityViolationException

java - 监听来自 TCP 服务器的传入消息会导致 StackOverflow

java - 使用 Kotlin 解析多列文件

java - .jar 适用于 Windows 但不适用于 Linux (stacktrace)

java - 每次我尝试在 mysql 数据库中插入数据(在 springboot java 上)时,Autowired 存储库都会收到 nullPointerException 错误

java - 在 Spring REST 中发送 jsp 响应以及状态代码