JSF 2.0

编程入门 行业动态 更新时间:2024-10-25 03:17:20
JSF 2.0 - 在URL中包含带&符号的脚本标记(JSF 2.0 - Including script tag with ampersand in URL)

我正在尝试添加Google Maps API脚本:

<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>

问题是&符号导致XML解析错误。 如果我这样做:

<script src="https://maps.googleapis.com/maps/api/js?v=3&amp;sensor=false" type="text/javascript"></script>

它是逐字逐句返回的。

知道如何在结果页面中获取预期的脚本标记吗?

I'm trying to include the Google Maps API script:

<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>

The problem is that the ampersand character causes an XML parsing error. If I do this:

<script src="https://maps.googleapis.com/maps/api/js?v=3&amp;sensor=false" type="text/javascript"></script>

it is returned verbatim.

Any idea how to get the intended script tag in the resulting page?

最满意答案

问题是&符号导致XML解析错误。 如果我这样做:

<script src="https://maps.googleapis.com/maps/api/js?v=3&amp;sensor=false" type="text/javascript"></script>

它是逐字逐句返回的。

它不应该。 这完全有效。 更重要的是,根据HTML规范要求使用&amp; 在任何HTML元素的href和src属性中分隔查询字符串中的多个参数。 您的逐字问题是由其他原因引起的。

The problem is that the ampersand character causes an XML parsing error. If I do this:

<script src="https://maps.googleapis.com/maps/api/js?v=3&amp;sensor=false" type="text/javascript"></script>

it is returned verbatim.

It shouldn't. It's perfectly valid. Even more, it's required as per the HTML spec to use &amp; to separate multiple parameters in query strings in any HTML element's href and src attribute. Your verbatim problem is caused by something else.

更多推荐

script>,><,<script,脚本,script,电脑培训,计算机培训,IT培训"/> <meta

本文发布于:2023-08-01 20:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363651.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JSF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!