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 ...
随机推荐
- linux 字符驱动
1 结构体说明: struct cdev { struct kobject kobj; // 每一个 cdev 都是一个 kobject st ...
- 14.Django自带的admin配置
admin有自己的默认显示,要自定义显示的样式,一般需要自己定义一个类,在自己定义的类里进行相应的设置,然后,把自己的类交给装饰器 交给装饰器的方法有两种: 1.@admin.register(Pub ...
- wechat JS-SKD (getLoaction) 定位显示百度map
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...
- 批处理设置IP地址
echo offecho 修改[本地连接]IP......netsh interface IP set address "本地连接" static 138.8.8.111 255. ...
- ABAP服务器文件操作
转自http://blog.itpub.net/547380/viewspace-876667/ 在程序设计开发过程中,很多要对文件进行操作,这又分为对本地文件操作和服务器文件操作.对本地文件操作使用 ...
- 从springmvc启动日志学习
javaee标准中,tomcat等web容器启动时走web.xml 先将各种contex-param 放到servletcontxt中变成parameter,然后开始启动容器,容器对外提供了liste ...
- 关于ionic开发中遇到的坑与总结
这次是第二次使用ionic开发混合app,今天算是对这个框架做一个总结,基础的我就不再重复了,网上都有教程.我就说说自己的心得和遇见的各种坑, 之后会陆续补充,想到什么说什么吧. 1.关于ionic效 ...
- Sqoop架构以及应用介绍
本篇文章在具体介绍Sqoop之前,先给大家用一个流程图介绍Hadoop业务的开发流程以及Sqoop在业务当中的实际地位. 如上图所示:在实际的业务当中,我们首先对原始数据集通过MapReduce进行 ...
- hadoop1.2.1 datanode 由于权限无法启动 expected: rwxr-xr-x
/************************************************************ STARTUP_MSG: Starting DataNode STARTUP ...
- python3 函数 二
1.函数嵌套 1.1函数嵌套定义 :在一个函数的内部,又定义另外一个函数. def f1(): x=1 def f2(): print('from f2') f ...