RESTEasy常用注解
- /**
- * @功能描述: (Path中的参数可以是固定值)
- */
- @GET
- @Path("test-get-param")
- @Produces(MediaType.APPLICATION_JSON)
- public Map<String, Object> getNotParam() {
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("say:", new Date());
- return map;
- }
- /**
- * @功能描述: (Path中的参数可以是正则表达式)
- */
- @Path("{id}")
- @GET
- @Produces("text/plain; charset=utf-8")
- public String getPathParam(@PathParam(value = "id") int id) {
- return "您好,您输入的数字为:" + id;
- }
- /**
- * @功能描述: (Path中的参数可以是多个正则表达式的组合)
- */
- @Path("{first}_{last}")
- @GET
- @Produces("application/json; charset=utf-8")
- public String getMorePathParam(@PathParam(value = "first") String first,
- @PathParam(value = "last") String last) {
- return "输入的信息为,first:" + first + ";last:" + last;
- }
二、@GET,@PUT,@POST,@DELETE,标注方法是用的HTTP请求的类型
- /**
- * @功能描述: (使用MatrixParam参数,在使用正则表达式方式入参时,
- * 部分参数和Path中无法匹配时,使用MatrixParam获取)
- */
- @GET
- @Path("{model}--{year}")
- @Produces("text/plain; charset=utf-8")
- public String getMatrixParam(@MatrixParam(value = "color") String color,
- @PathParam(value = "year") String year,
- @PathParam(value = "model") String model) {
- return "color: " + color + "; year: " + year + "; model: " + model;
- }
参数为:color: black; year: context; model: test
- /**
- * @功能描述: (Context获取Path路径,Matrix参数,PathParam参数)
- */
- @GET
- @Path("test-context/{id}")
- @Produces("text/plain; charset=utf-8")
- public String getContext(@Context UriInfo uriInfo) {
- String path = uriInfo.getPath();
- List<PathSegment> lsps = uriInfo.getPathSegments();
- String psString = "";
- for (PathSegment ps : lsps) {
- psString = psString + JSON.toJSONString(ps) + "; ";
- }
- MultivaluedMap<String, String> map = uriInfo.getPathParameters();
- return "path:" + path + "; lsps:" + psString + "; map:"
- + JSON.toJSONString(map);
- } <span style="color:#808080;"> </span><span style="font-family:'Microsoft YaHei UI';font-size:10.5pt; line-height:1.5"> </span>
RESTEasy常用注解的更多相关文章
- Spring系列之Spring常用注解总结
传统的Spring做法是使用.xml文件来对bean进行注入或者是配置aop.事物,这么做有两个缺点:1.如果所有的内容都配置在.xml文件中,那么.xml文件将会十分庞大:如果按需求分开.xml文件 ...
- SpringMVC常用注解實例詳解3:@ResponseBody
我的開發環境框架: springmvc+spring+freemarker開發工具: springsource-tool-suite-2.9.0JDK版本: 1.6.0_29tomcat ...
- SpringMVC常用注解實例詳解2:@ModelAttribute
我的開發環境框架: springmvc+spring+freemarker開發工具: springsource-tool-suite-2.9.0JDK版本: 1.6.0_29tomcat ...
- Spring常用注解汇总
本文汇总了Spring的常用注解,以方便大家查询和使用,具体如下: 使用注解之前要开启自动扫描功能 其中base-package为需要扫描的包(含子包). <context:component- ...
- Spring常用注解,自动扫描装配Bean
1 引入context命名空间(在Spring的配置文件中),配置文件如下: xmlns:context="http://www.springframework.org/schema/con ...
- springmvc常用注解与类型转换
springmvc常用注解与类型转换 一:前置 spring -servlet.xml 注入 <!-- 启用spring mvc 注解 --> <context:annotation ...
- SpringMVC常用注解,返回方式,路径匹配形式,验证
常用注解元素 @Controller 标注在Bean的类定义处 @RequestMapping 真正让Bean具备 Spring MVC Controller 功能的是 @RequestMapping ...
- SpringMVC 常用注解
本文参考了博客,具体请见:http://www.cnblogs.com/leskang/p/5445698.html Spring MVC的常用注解 1.@Controller @Controller ...
- spring注解开发中常用注解以及简单配置
一.spring注解开发中常用注解以及简单配置 1.为什么要用注解开发:spring的核心是Ioc容器和Aop,对于传统的Ioc编程来说我们需要在spring的配置文件中邪大量的bean来向sprin ...
随机推荐
- [note]高精度模板
高精度模板 先定义一个struct struct gj{ int l,s[N]; bool fh; void Print(){ if(fh)putchar('-'); for(int i=l;i> ...
- Django 视图之CBV
CBV 所谓的CBV(class base view) 在视图里面,用类的方式来写逻辑 那么对于FBV,CBV有什么优势? CBV(class base views) 就是在视图里使用类处理请求. P ...
- 我的Android进阶之旅------>Android疯狂连连看游戏的实现之状态数据模型(三)
对于游戏玩家而言,游戏界面上看到的"元素"千变万化:但是对于游戏开发者而言,游戏界面上的元素在底层都是一些数据,不同数据所绘制的图片有所差异而已.因此建立游戏的状态数据模型是实现游 ...
- Linux c编程:线程属性
前面介绍了pthread_create函数,并且当时的例子中,传入的参数都是空指针,而不是指向pthread_attr_t结构的指针.可以使用pthread_attr_t结构修改线程默认属性,并把这些 ...
- Redis持久化——问题定位与优化(三)
核心知识点: 1.fork操作 a.在RDB或AOF重写时,会执行fork操作创建子进程,fork操作是一个重量级操作. b.改善fork操作耗时的手段:避免使用Xen.配置Redis实例最大使用内存 ...
- im协议设计选型【转】
一.im协议的分层设计所谓“协议”是双方共同遵守的规则,例如:离婚协议,停战协议.协议有语法.语义.时序三要素.(1)语法:即数据与控制信息的结构或格式(2)语义:即需要发出何种控制信息,完成何种动作 ...
- LeetCode:最少移动次数使得数组元素相等||【462】
LeetCode:最少移动次数使得数组元素相等||[462] 题目描述 给定一个非空整数数组,找到使所有数组元素相等所需的最小移动数,其中每次移动可将选定的一个元素加1或减1. 您可以假设数组的长度最 ...
- Android:日常学习笔记(10)———使用LitePal操作数据库
Android:日常学习笔记(10)———使用LitePal操作数据库 引入LitePal 什么是LitePal LitePal是一款开源的Android数据库框架,采用了对象关系映射(ORM)的模式 ...
- iOS 代码延迟执行
1. [NSTread sleepForTimeInterval:0.8f] 这个方法 实际效果 好比打断点 等你再恢复断点执行 2. [self performSelector:@selector ...
- Scala window下安装
第一步:Java 设置 检测方法前文已说明,这里不再描述. 如果还为安装,可以参考我们的Java 开发环境配置. 接下来,我们可以从 Scala 官网地址 http://www.scala-lang. ...