【发布时间】:2018-10-18 07:40:19
【问题描述】:
我们将 jersey 2 用于 Java 中的 REST Web 服务。
我们创建了javax.ws.rs.container.ContainerRequestFilter 和javax.ws.rs.container.ContainerResponseFilter
在发送 appKey、secret、token 等请求时,我们有标头。 如果我们从 Postman 发出请求,它会给出所有标头及其值,如下所示:
{
host=[localhost:8080],
connection=[keep-alive],
authorization=[bearer <token>],
cache-control=[no-cache],
x-request-id=[<request-id>],
x-api-secret=[<secret>],
user-agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36],
x-api-key=[api-key],
postman-token=[<postman-token>],
accept=[*/*],
accept-encoding=[gzip, deflate, br],
accept-language=[en-US,en;q=0.9]
}
如果我们从网络客户端发出请求,它会在access-control-request-headers 下给出如下值(只有键,而不是它们的值):
{
host=[localhost:8080],
connection=[keep-alive],
access-control-request-method=[GET],
origin=[http://resttesttest.com],
user-agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36],
access-control-request-headers=[authorization,x-api-key,x-api-secret,x-request-id],
accept=[*/*],
accept-encoding=[gzip, deflate, br],
accept-language=[en-US,en;q=0.9]
}
为什么它不给头参数值?
如何获得这些?
请指导我。 提前致谢!
【问题讨论】:
标签: java rest web-services jersey-2.0