use*_*378 13 java jax-rs resteasy
什么是Resteasy?RESTEasy和JAX-RS有什么区别?@PathParam和之间有什么区别@QueryParam?
查询参数从请求URI查询参数中提取,并使用方法参数参数中的javax.ws.rs.QueryParam批注指定.
例:
@Path("smooth")
@GET
public Response smooth(
@DefaultValue("2") @QueryParam("step") int step,
@QueryParam("minm") boolean hasMin,
@QueryParam("test") String test
) { ... }
URL: http://domain:port/context/XXX/smooth?step=1&minm=true&test=value
Run Code Online (Sandbox Code Playgroud)
URI 路径参数从请求URI中提取,参数名称对应于@Path类级别注释中指定的URI路径模板变量名称.使用方法参数参数中的javax.ws.rs.PathParam批注指定URI参数
例:
@Path("/{userName}")
public class MyResourceBean {
...
@GET
public String printUserName(@PathParam("userName") String userId) {
...
}
}
URL: http://domain:port/context/XXX/naveen
Run Code Online (Sandbox Code Playgroud)
这里,naveen将其作为userName(Path参数)
JAX-RS是一组接口和类,没有属于javax.ws.rs.*包的实际实现(它们是Oracle的Java SE 6的一部分).
RESTEasy以及例如Jersey或Apache CXF是JAX-RS类的开源实现.
在编译期间,您只需要JAX-RS.在运行时,您只需要其中一个实现.