解决方法:

客户端在发送GET URL请求的时候,将含有中文的URL编码即可

比如:

原始:http://localhost/qk/rest/user_album_api/get_user_albums_by_desc/album_desc/风景/page_num/1/page_size/3

URL转码 http://tool.oschina.net/encode?type=4

结果是:http://localhost/qk/rest/user_album_api/get_user_albums_by_desc/album_desc/%E9%A3%8E%E6%99%AF/page_num/1/page_size/3

 

在服务器端,再进行对该编码的字段进行解码即可,用PHP函数string urldecode ( string $str )

 

(PHP 4, PHP 5)

urldecode — 解码已编码的 URL 字符串

说明

string urldecode ( string $str )

解码给出的已编码字符串中的任何 %##。 加号('+')被解码成一个空格字符。

参数

 

str

要解码的字符串。

返回值

返回解码后的字符串。

范例

 

Example #1 urldecode() 示例

<?php
$query = "my=apples&are=green+and+red";

foreach (explode('&', $query) as $chunk) {
    $param = explode("=", $chunk);

    if ($param) {
        printf("Value for parameter \"%s\" is \"%s\"<br/>\n", urldecode($param[0]), urldecode($param[1]));
    }
}
?>

相关文章:

  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-10
  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2021-12-25
相关资源
相似解决方案