【问题标题】:using Path Variables in Apache Camel Rest在 Apache Camel Rest 中使用路径变量
【发布时间】:2016-01-05 15:22:55
【问题描述】:

如何访问 Apache Camel Rest 模块中的 PathVariables?

我定义了这样的路由(遵循documentation 中的“使用基本路径”):

rest("/customers/")
.get("/{id}").to("direct:customerDetail")

我怎样才能在以下路由中保留{id}-参数?

基本上我想知道骆驼提供什么而不是@PathVariable(见以下示例)

@RequestMapping(value="/customers/{id}", method = RequestMethod.GET)
public Customer customerDetail(@PathVariable String cId) {
    return getCustomer(cId);
}

【问题讨论】:

    标签: java web-services rest apache-camel


    【解决方案1】:

    原来这真的很简单:

    public Customer customerDetail(Exchange exchange){
        String id = exchange.getIn().getHeader("id").toString();
        return getCustomer(id);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多