相关疑难解决方法(0)

带有{}大括号的Spring MVC @Path变量

我正在使用弹簧靴开发应用程序.在REST控制器中,我更喜欢使用路径变量(@PathVariabale注释).我的代码获取路径变量,但它在网址中包含{}大括号.请任何人建议我解决这个问题

@RequestMapping(value = "/user/item/{loginName}", method = RequestMethod.GET)
public void getSourceDetails(@PathVariable String loginName) {
    try {
        System.out.println(loginName);
        // it print like this  {john}
    } catch (Exception e) {
        LOG.error(e);
    }
}
Run Code Online (Sandbox Code Playgroud)

网址

http://localhost:8080/user/item/{john}
Run Code Online (Sandbox Code Playgroud)

输出控制器

{约翰}

java spring spring-mvc spring-boot

23
推荐指数
1
解决办法
6万
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1

spring-mvc ×1