java restful @QueryParam获取JSP表单的值,为什么有的可以拿到,有的是null
1条回答 默认 最新
- Jag_xiaoweizhu 2016-10-27 10:16关注
Java代码 收藏代码
@Path("/users")
public class UserService {@GET @Path("/query") public Response getUsers(@Context UriInfo info) { String from = info.getQueryParameters().getFirst("from"); String to = info.getQueryParameters().getFirst("to"); List<String> orderBy = info.getQueryParameters().get("orderBy"); return Response .status(200) .entity("getUsers is called, from : " + from + ", to : " + to + ", orderBy" + orderBy.toString()).build(); }
URL;users/query?from=100&to=200&orderBy=age&orderBy=name
输出为:
getUsers is called, from : 100, to : 200, orderBy[age, name]
注意这里把orderby后的两个参数读入为LIST处理了.解决 无用评论 打赏 举报