代码:

    public static void main(String[] args) {

            Student st = new Student("Adriana", "Barrer", 12, 9);
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(
JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
Client client = Client.create(clientConfig);
WebResource webResource = client
.resource("http://localhost:8080/JerseyJSONExample/rest/jsonServices/send");
ClientResponse response = webResource.accept("application/json")
.type("application/json").post(ClientResponse.class, st);
if (response.getStatus() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatus());
}
String output = response.getEntity(String.class);
System.out.println("Server response .... \n");
System.out.println(output);
}

资源中代码:

    @POST
@Path("/send")
@Consumes(MediaType.APPLICATION_JSON)
public Response consumeJSON( Student student ) {
System.out.println("student :"+student);
System.out.println("student content:"+student.getFirstName());
String output = student.toString(); return Response.status(200).entity(output).build();
}

实体bean中必须要有默认的空构造器。

Jersey Client Post Bean参数的更多相关文章

  1. Jersey Client传递中文参数

    客户端需要客户端的包: <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jerse ...

  2. jersey client上传下载文件

    jersey client上传文件demo File file = new File("/tmp/test.jpg"); System.out.println(file.exist ...

  3. RESTful Java client with Apache HttpClient / URL /Jersey client

    JSON example with Jersey + Jackson Jersey client examples RESTful Java client with RESTEasy client f ...

  4. 由hbase.client.scanner.caching参数引发的血案(转)

    转自:http://blog.csdn.net/rzhzhz/article/details/7536285 环境描述 Hadoop 0.20.203.0Hbase 0.90.3Hive 0.80.1 ...

  5. Spring <bean> 参数意义

    1.id bean的唯一标识, 2.class 类的完全限定名, 3.parent 父类bean定义的名字. 如果没有任何声明,会使用父bean,但是也可以重写父类.重写父类时,子bean 必须与父b ...

  6. tomcat web容器中,调用jersey client端报错的处理

    在web工程中,写main方法,运行ok. 发布到tomcat中后,报错. javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/r ...

  7. Jersey(1.19.1) - Client API, Ease of use and reusing JAX-RS artifacts

    Since a resource is represented as a Java type it makes it easy to configure, pass around and inject ...

  8. Jersey(1.19.1) - Client API, Proxy Configuration

    为 Jersey Client 设置代理,可以使用带有 ClientHandler 参数的构造方法创建 Client 实例. public static void main(String[] args ...

  9. Jersey(1.19.1) - Client API, Uniform Interface Constraint

    The Jersey client API is a high-level Java based API for interoperating with RESTful Web services. I ...

随机推荐

  1. express中使用ejs

    [express中使用ejs] 1.添加 ejs 依赖. npm install ejs --save 2.设置 view engine 为 ejs 即可.

  2. 结对项目3-bug的三种状态

    这周和小伙伴结对构造程序,来深刻理解软件测试中,bug发现的三种状态. 1:不能触发Fault 2:触发Fault,但是不能触发Error 3:触发Error,但是不能产生Failure 我们完成的代 ...

  3. manacher最长回文序列c++

    算法真心读不懂 #include <iostream>#include<string>#include<cstring> using namespace std;c ...

  4. jquery 赋值时不触发change事件解决

    $("#optionsId").change(function(){ $("#selectOptionsText").val('测试'); }); $(&quo ...

  5. 【转】Repository 返回 IQueryable?还是 IEnumerable?

    这是一个很有意思的问题,我们一步一步来探讨,首先需要明确两个概念(来自 MSDN): IQueryable:提供对未指定数据类型的特定数据源的查询进行计算的功能. IEnumerable:公开枚举数, ...

  6. Vmware迁移以后eth0消失,无法上网

    一个再普通不过的大神帮助小菜做虚拟机镜像的事情: 小张:帮我做个Vmware下的Ubuntu镜像吧,大神. 小黄:好啊,等我一下,下午发给你. 经过一番操作,小黄顺利的做出了一个虚拟机操作系统 小黄: ...

  7. Devexpress RichEditControl 导入word文件后字体变为方正姚体的解决方案

    最近在做一个排版软件,用过RichEditControl 导入外部Word文件的时候,发现导的文件后字体会变成“方正姚体”,官方这个BUG至少在V16.1版本尚未解决,翻阅了大量资料,发现 DevEx ...

  8. 我对于UI设计这个领域的理解

    User Interface(UI),包括三部分用户.界面以及用户与界面之间的交互关系.UI设计则是指对软件的人机交互.操作逻辑.界面美观的整体设计. 如何看待UI设计这个领域? 任何一个行业的出现都 ...

  9. How to Set Up an Rsync Daemon on Your Linux Server

    Introduction This tutorial will take you through setting up an rsync daemon on your Linux server. Yo ...

  10. [Selenium]验证点了某个Button之后无反应

    期望:点了某个Button,无反应 问题:怎么去验证无反应 WebElement webElement = page.getICORemove(); SeleniumUtil.hover(page.g ...