CI中REST URL含有中文怎么处理(报错:The URI you submitted has disallowed characters)

简介: 解决方法: 客户端在发送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.

解决方法:

客户端在发送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 )

 

urldecode

(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]));
    }
}
?>
如何联系我:【万里虎】www.bravetiger.cn 【QQ】3396726884 (咨询问题100元起,帮助解决问题500元起) 【博客】http://www.cnblogs.com/kenshinobiy/
目录
相关文章
|
8天前
|
iOS开发
url中带中文,ios报错问题
url中带中文,ios报错问题
|
2月前
|
弹性计算 运维 Kubernetes
阿里云云效操作报错合集之构建流程中遇到 "origin_value 类型错误,取不到DOCKER_URL" 这样的错误,该怎么办
本合集将整理呈现用户在使用过程中遇到的报错及其对应的解决办法,包括但不限于账户权限设置错误、项目配置不正确、代码提交冲突、构建任务执行失败、测试环境异常、需求流转阻塞等问题。阿里云云效是一站式企业级研发协同和DevOps平台,为企业提供从需求规划、开发、测试、发布到运维、运营的全流程端到端服务和工具支撑,致力于提升企业的研发效能和创新能力。
|
3月前
|
XML 数据格式
蓝易云 - URI和URL和URN区别
总的来说,URI是一个广义的概念,包括URL和URN。URL提供了资源的位置信息,URN提供了资源的唯一名称。
34 2
|
2月前
|
Web App开发 前端开发
canvas保存图片时,谷歌浏览器Chrome报错【解决方案】Not allowed to navigate top frame to data URL
canvas保存图片时,谷歌浏览器Chrome报错【解决方案】Not allowed to navigate top frame to data URL
82 0
|
3月前
|
Java 关系型数据库 MySQL
【已解决】SpringBoot 启动报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no emb
【已解决】SpringBoot 启动报错:Failed to configure a DataSource: ‘url‘ attribute is not specified and no emb
172 0
|
4月前
|
缓存 JavaScript
报错:cannot read properties of undefined “reading url“
报错:cannot read properties of undefined “reading url“
126 6
|
4月前
|
关系型数据库 MySQL Java
报错 create connection SQLException, url: jdbc:mysql://noreggie?serverTimezone=Asia/Shanghai&useUnicod
报错 create connection SQLException, url: jdbc:mysql://noreggie?serverTimezone=Asia/Shanghai&useUnicod
|
4月前
|
Java 数据库
【问题记录(已解决)】springboot整合ssm报错‘url‘ attribute is not specified and no embedded datasource
【问题记录(已解决)】springboot整合ssm报错‘url‘ attribute is not specified and no embedded datasource
|
1月前
|
开发框架 前端开发 .NET
Asp.net Webapi 的 Post 方法不能把参数加到 URL 中?试试这样写
Asp.net Webapi 的 Post 方法不能把参数加到 URL 中?试试这样写
|
1月前
|
Java
JAVA 获取 URL 指定参数的值
JAVA 获取 URL 指定参数的值
32 0