IE 11 中的 GWT Window.open 错误解释了查询参数 °=123
GWT Window.open in IE 11 misinterprets query parameter °=123
在 GWT
应用程序中,我尝试打开一个 Window
并传递包含查询参数的 url
。碰巧有一个参数被命名为:deg_test
,因此格式化后的 url 类似于:http://localhost:8888/mymodule/search?param1=value1¶m2=value2°_test=123
。
在 Chrome
和 Firefox
中,window 按预期打开,但是在 IE 11
中, °_
部分被误解为 °
并且它被转换为度数符号 (º) 并打破 url!
示例代码:
String query = "?param1=value1¶m2=value2°_test=123";
com.google.gwt.user.client.Window.open("http://localhost:8888/mymodule/search"
+ URL.encode(query), "_blank", "resizable=yes"
IE window URL: http://localhost:8888/mymodule/search?param1=value1¶m2=value2°_test=123
如果我使用 URL.encodeQueryString
方法而不是 URL.encode
方法,?
和 &
都将被编码并且服务器将抱怨 404
实际上这不是 GWT 问题,只是 IE 的一般问题。它将转换任何看起来像实体的东西(末尾没有 ;
),例如:
°
、<
、>
分别为 °
、<
、>
。参见 this question。
作为快速解决方法,我建议您将 deg_test
参数放在查询的开头。这样你就不会得到 °
片段,而是 ?deg
。
?deg_test=123¶m1=value1¶m2=value2
它会起作用。
在 GWT
应用程序中,我尝试打开一个 Window
并传递包含查询参数的 url
。碰巧有一个参数被命名为:deg_test
,因此格式化后的 url 类似于:http://localhost:8888/mymodule/search?param1=value1¶m2=value2°_test=123
。
在 Chrome
和 Firefox
中,window 按预期打开,但是在 IE 11
中, °_
部分被误解为 °
并且它被转换为度数符号 (º) 并打破 url!
示例代码:
String query = "?param1=value1¶m2=value2°_test=123";
com.google.gwt.user.client.Window.open("http://localhost:8888/mymodule/search"
+ URL.encode(query), "_blank", "resizable=yes"
IE window URL: http://localhost:8888/mymodule/search?param1=value1¶m2=value2°_test=123
如果我使用 URL.encodeQueryString
方法而不是 URL.encode
方法,?
和 &
都将被编码并且服务器将抱怨 404
实际上这不是 GWT 问题,只是 IE 的一般问题。它将转换任何看起来像实体的东西(末尾没有 ;
),例如:
°
、<
、>
分别为 °
、<
、>
。参见 this question。
作为快速解决方法,我建议您将 deg_test
参数放在查询的开头。这样你就不会得到 °
片段,而是 ?deg
。
?deg_test=123¶m1=value1¶m2=value2
它会起作用。