【问题标题】:Retrieve path param AbstractPhaseInterceptor cxf检索路径参数 AbstractPhaseInterceptor cxf
【发布时间】:2015-11-07 15:14:17
【问题描述】:

我正在开发一个具有这种结构的 REST Web 服务

http://localhost:8080/context/login/{用户}/{密码}

这个请求的例子是

http://localhost:8080/context/login/admin/admin

我在我的 spring 应用程序的 applicationContext.xml 中配置了一个 AbstractPhaseInterceptor。而拦截器类是

公共类 TokenInInterceptor 扩展 AbstractPhaseInterceptor {

public TokenInInterceptor() {
    super(Phase.READ);
}

public void handleMessage(Message message) {

}

}

我想从handleMessage方法中的对象消息中检索参数用户和密码,但是我找不到它在哪里。

有谁知道我如何检索这些参数?

谢谢

【问题讨论】:

    标签: java rest cxf interceptor


    【解决方案1】:

    你可以这样做:

    UriInfo uriInfo = new UriInfoImpl(message);
    MetadataMap<String, String> metadataMap = (MetadataMap<String, String>) uriInfo.getPathParameters();
    User user = metadataMap.getFirst("user");
    String password = metadataMap.getFirst("password");
    

    【讨论】:

      猜你喜欢
      • 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
      相关资源
      最近更新 更多