spring-boot - @PathVariable 根本不起作用

标签 spring-boot

在我的 Spring Boot 应用程序中,我添加了一个 API

@RequestMapping(value = "/abc/{input}", method=RequestMethod.GET)
@ResponseBody
public WhitelistStatus getInput(@PathVariable("input") String input);

我部署了这个应用程序并调用了电话 - http://localhost:8080/abc/123

我在我的代码中放置了一个调试点,应该为“123”的路径变量输入始终为空。

我一直在努力解决这个问题。 URL 中没有歧义,因为这是唯一的 API。有人可以告诉我我在这里做错了什么吗?

最佳答案

好吧,我发现了问题。我还必须在实现方法中添加 @PathVariable 注释。我只是先在界面中使用了它,它起作用了!

关于spring-boot - @PathVariable 根本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42854834/

相关文章:

java - 需要配置类中的属性

java - 从 spring boot simpleJDBCcall 调用 PL SQL 过程时出错

Java - 连接被对等方重置 : socket write error

java - Spring boot 1.5.2.RELEASE 在静态方法中访问 application.yml 属性

java - AWS CodeStar - AWS Elastic Beanstalk 与 Amazon EC2

spring-boot - 升级到 spring-boot 1.3.0.RC1 由于 "Circular view path..."导致 ServletException

spring-boot - 在 Spring Boot Rest API 中将 Map 用作 @RequestBody 不起作用

java - 无法在 Spring Boot 2.1.1.RELEASE 中访问消息源

java - 如何在rest api中使用hashmap返回多值参数

java - 将 Elasticsearch 与 Spring Boot 结合使用时出错