Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 查询参数中的AsyncRestTemplate“”符号编码_Java_Google Maps_Spring Boot_Encoding_Asyncresttemplate - Fatal编程技术网

Java 查询参数中的AsyncRestTemplate“”符号编码

Java 查询参数中的AsyncRestTemplate“”符号编码,java,google-maps,spring-boot,encoding,asyncresttemplate,Java,Google Maps,Spring Boot,Encoding,Asyncresttemplate,我正在使用Springboot 1.5.2服务对Google地图进行API调用。不幸的是,我的一些搜索字符串包含磅/哈希标记符号 在我的搜索参数中没有正确编码。我正在使用这种方法 下面是地址05406的示例,地址为伯灵顿,309学院街10号,VT: 请注意,仍在address参数中,此时应根据将其编码为%23 深入到调试器中,似乎10&key=some_键之后的字符串被用作URL的名称。因此,为什么数据永远不会被编码 是否有人能够使用AsyncRestTemplate在查询参数中提交签名 我唯一

我正在使用Springboot 1.5.2服务对Google地图进行API调用。不幸的是,我的一些搜索字符串包含磅/哈希标记符号 在我的搜索参数中没有正确编码。我正在使用这种方法

下面是地址05406的示例,地址为伯灵顿,309学院街10号,VT:

请注意,仍在address参数中,此时应根据将其编码为%23

深入到调试器中,似乎10&key=some_键之后的字符串被用作URL的名称。因此,为什么数据永远不会被编码

是否有人能够使用AsyncRestTemplate在查询参数中提交签名

我唯一能想到的是用数字替换,这确实有效,但感觉不太好/不太理想

感谢您的帮助。

请注意,googleUrl是一个模板,其中插入了编码的参数。因此,不能将实际参数作为url的一部分提供。您需要将字符串更改为这样的模板

final String googleUrl = "https://maps.googleapis.com/maps/api/geocode/json?address={address}&key={key}";
这将返回正确的编码:

https://maps.googleapis.com/maps/api/geocode/json?address=05406,%20VT,%20BURLINGTON,%20309%20College%20St%20%2310&key=some_key
final String googleUrl = "https://maps.googleapis.com/maps/api/geocode/json?address={address}&key={key}";
https://maps.googleapis.com/maps/api/geocode/json?address=05406,%20VT,%20BURLINGTON,%20309%20College%20St%20%2310&key=some_key