@path 不限于简单的路径表达式,也可以在@path中插入正则表达式,通过如下格式:
"{" variable-name [ ":" regular-expression ] "}"
package com.example.rest.resteasy.service;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
@Path("/hello")
public class HelloWorldRestService {
// @Path and regular expression mappings
@GET
@Path("{var:.*}/stuff")
public Response getStuff() {
String result = "RESTEasy getStuff() is called! ";
return Response.status(200).entity(result).build();
}
}
请求1:http://localhost:8080/resteasy-example/hello/aa/stuff
请求2:http://localhost:8080/resteasy-example/hello/aa/bb/stuff
RESTEasy getStuff() is called!
注:正则表达式中有一部分是可选的,如果没有提供表达式,默认匹配一个特定的段,例如:
@Path("/hello/{var}/stuff")
可以匹配:
GET /hello/foo/stuff
GET /hello/bar/stuff
但是不能匹配:
GET /hello/a/bunch/of/stuff
- 大小: 4 KB
分享到:
相关推荐
* 不需要配置文件,只要把JARs文件放到类路径里面,添加 @Path 注解就可以了。 * 完全的把 RESTEeasy 配置作为Seam 组件来看待。 * HTTP 请求由Seam来提供,不需要一个额外的Servlet。 * Resources 和providers...
@Path,标注资源类或方法的相对路径 @GET,@PUT,@POST,@DELETE,标注方法是用的HTTP请求的类型 @Produces,标注返回的MIME媒体类型 @Consumes,标注可接受请求的MIME媒体类型 @PathParam,@QueryParam,@...
resteasy
Spring整合RestEasy示例工程源码,Spring+Jetty+RestEasy
resteasy不使用tomcat使用netty实现,实现了高性能,也可以不需要tomcat的容器,一个主函数就能执行
resteasy入门级文档、如何使用Restful进行WebService的开发简介及相关RestEasy相关资源的链接
该资源是java restful的应用框架resteasy---实现了jax-rs规范的一个demo,如有疑问请联系caizhh2009@gmail.com
resteasy-spring-netty Resteasy + Spring + Netty sample Inject resteasy provider / controllers as spring bean Authentication ===================== Run at Main.java ...@Path,标注资源类或方
详细描述了restEasy在servlet3.0前后的不同使用方法;restEasy 结合httpServer 无需容器开发;restEasy的通用差错拦截;附详细实现源码!
resteasy讲解
使用RESTEasy+guice实现上传下载文件
resteasy简单demo使用的jar包
RESTEasy入门经典.docx
resteasy-jaxrs-2.3.2框架源码。希望您了解Resteasy框架有所帮助
resteasy参考文档及jar包
RESTEasy JSON DEMO
resteasy-reference-guide-en-US.pdf
Resteasy英文文档,开发rest风格的API接口
介绍了RESTEasy中的安全机制的使用方法