客户端需要客户端的包:

        <dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.18</version>
</dependency>

版本和之前对应。

代码如下:

package client;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; /**
* Created by wl on 2014/10/15.
*/
public class RestfulClient {
public static void main(String args[]){
String url="http://localhost:8080/services/hello/";
Client client=Client.create();
try {
url+= URLEncoder.encode("你好啊","utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
WebResource resource=client.resource(url);
ClientResponse response=resource.get(ClientResponse.class);
String entity=response.getEntity(String.class);
System.out.println(entity); }
}

他对应的服务端方法:

    //带参数
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("{name}")
public String sayHello(@PathParam("name")String name){
return "hello,"+name;
}

所以,结果是打印:

hello,你好啊

Jersey Client传递中文参数的更多相关文章

  1. Web报表页面如何传递中文参数

    1.场景描述 在用报表开发工具FineReport设计的web报表中,给iframe设置src嵌入某个报表时,往往会给报表传递初始的参数值,例如: <iframe id="report ...

  2. GET方法传递中文参数乱码解决办法

    1.在页面中对你的URL进行编码 使用------encodeURI(你要使用的中文参数值)如:...?username"+encodeURI(“小甜甜") 2.在后台通过解码来接 ...

  3. js的url中传递中文参数乱码,如何获取url中参数问题

    一:Js的Url中传递中文参数乱码问题,重点:encodeURI编码,decodeURI解码: 1.传参页面Javascript代码: <script type=”text/javascript ...

  4. jquery与后台相互传递中文参数乱码

    前端.后台传递中文参数,乱码的情况: var a="参数乱码"; //编译两次        window.location.href=encodeURI(encodeURI(&q ...

  5. JS中的的Url传递中文参数乱码,如何获取Url中参数问题

    一:Js的Url中传递中文参数乱码问题,重点:encodeURI编码,decodeURI解码: 1.传参页面Javascript代码:<script type=”text/javascript” ...

  6. SSH通过超链接传递中文参数出现乱码问题

    通过超链接传递中文参数出现乱码问题 tomcat中的server.xml文件中修改如下配置: <Connector port="8080" protocol="HT ...

  7. Js的Url中传递中文参数乱码的解决

    一:Js的Url中传递中文参数乱码问题,重点:encodeURI编码,decodeURI解码: 1.传参页面Javascript代码: 2. 接收参数页面:test02.html 二:如何获取Url& ...

  8. 通过URL传递中文参数的乱码处理

    环境:web.xml中配置了 <filter> <filter-name>encodingFilter</filter-name> <filter-class ...

  9. url 传递中文参数乱码问题的终极解决方法。

    估计很多人在做web开发的时候,都会碰到过url传递中文参数,有时候会出现乱码的问题,但有些项目或者环境,又不会有问题.当遇到乱码的时候,上网找了很多解决方案,比如: 页面设置它的编码方式,改成utf ...

随机推荐

  1. Spring AOP开发

    --------------------siwuxie095                                 Spring AOP 开发         1.在 Spring 中进行 ...

  2. 二级联动的作业&左右移动作业

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. iOS 基于MVC设计模式的基类设计

    iOS 基于MVC设计模式的基类设计 https://www.jianshu.com/p/3b580ffdae00

  4. 解决安装Apache中出现checking for APR... no configure: error: APR not found. Please read the documentation的问题

    Linux中安装Apache 编译出现问题: 解决办法: 1.下载所需要的软件包 wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz wg ...

  5. 《Google软件测试之道》摘录

    以下是最近看的一本书<Google软件测试之道>里的一些摘录,收获很多. 1.讨论测试开发比并没有什么意义,如果你是一名开发人员,同时也是一名测试人员,如果你的职位头衔上有测试的字样,你的 ...

  6. 在iframe框架中全屏不好使的原因

    遇到的问题:我是在iframe框架中添加了一个插件在360和火狐中不好使,将allowfullscreen="true" 属性配置好就没问题了: 可能出现的原因:将allowful ...

  7. .net core web api swagger 配置笔记

    参考网址: --配置步骤见如下链接https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/web-api-help-pages-using-swa ...

  8. ffmpeg 入门教程

    1.在terminal,安装ffmpeg开源库 #brew install ffmpeg 2.新建一个目录first_ffmpeg,并在first_ffmpeg目录下新建ffmpeg目录 3.拷贝/u ...

  9. Zookeeper 系列(四)ZKClient API

    Zookeeper 系列(四)ZKClient API 环境准备: <dependency> <groupId>com.101tec</groupId> <a ...

  10. /etc/inittab加入自动启动格式

    R01:35:respawn:/usr/bin/exe_program 说明 R01:标识,每一行必须唯一(R01并无特殊含义,可自定义). 35:有效模式,3字符界面启动,5图形界面启动 respa ...