我正在构建一个通用 Web 服务,需要将所有查询参数抓取到一个字符串中以供以后解析.我该怎么做?
I am building a generic web service and need to grab all the query parameters into one string for later parsing. How can I do this?
您可以通过 @QueryParam("name")
访问单个参数或通过上下文访问所有参数:
You can access a single param via @QueryParam("name")
or all of the params via the context:
@POST
public Response postSomething(@QueryParam("name") String name, @Context UriInfo uriInfo, String content) {
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
String nameParam = queryParams.getFirst("name");
}
关键是 @Context
jax-rs注解,可用于访问:
The key is the @Context
jax-rs annotation, which can be used to access:
UriInfo、请求、HttpHeaders、安全上下文,提供者
UriInfo, Request, HttpHeaders, SecurityContext, Providers
上一篇:使用 Jersey 客户端的 HTTPS客户端、Jersey、HTTPS
下一篇:我如何$访问我activites p $ pvent其他Android应用activites、pvent、Android