1:@Path上定义的参数,可以使用正则表达式
如:@Path("users/{username: [a-zA-Z][a-zA-Z_0-9]*}")
此处,如果用户输出的参数不匹配,就会报404(Not Found)错误。
2:顺序作用域
/**
*顺序作用域<br>
* Http 方法: GET <br>
* API 路径: /rest/test/{begeinMonth:\\d+},{begeinYear:\\d+}-{endMonth:\\d+},{endYear:\\d+}<br>
* 方 法 名: test3 <br>
* 返回的MIME媒体类型:@Produces("application/json;charset=utf-8")<br>
* @return javax.ws.rs.core.Response
* @throws Throwable
*/
@GET
@Path("{begeinMonth:\\d+},{endYear:\\d+}")
@Produces("application/json;charset=utf-8")
public Response test3(@PathParam("begeinMonth") String begeinMonth,
@PathParam("begeinYear") String begeinYear,
@PathParam("endMonth") String endMonth,
@PathParam("endYear") String endYear) throws Throwable {
return Response.status(200).entity(begeinYear + "-"+endMonth+"至" + endYear+"-"+endMonth).build();
}
//d+表示参数为数字,并且必须出现一次!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。