与GET参数的有效链接

时间:2011-02-01 20:08:12

标签: xhtml

如何将带参数的有效链接放入我的页面?

当我运行验证器时,它会出错:

Line 37, Column 37: reference to entity "p" for which no system identifier could be generated
<li><a href="index.php?c=tutorials&p=cat&cid=1" >LINK</a></li>

5 个答案:

答案 0 :(得分:4)

从这里开始 http://css-discuss.incutio.com/wiki/Code_Validation

到目前为止最常见的错误看起来像这样: 引用实体“BV_Engine”,其中不能生成系统标识符。 这意味着你只有一个带有&amp;的URL。在其中签名,你忘了逃避。

例如:  <a href="script.cgi?id=4&BV_Engine=20">

&amp;登录此网址应为&amp ;.实际上ALL&amp;应该以这种方式转义HTML文档中的标志,以避免混淆HTML解析器。对于上面的示例,将其替换为

<a href="script.cgi?id=4&amp;BV_Engine=20">

答案 1 :(得分:2)

逃离你的&符号:

<li><a href="index.php?c=tutorials&amp;p=cat&amp;cid=1" >LINK</a></li>

答案 2 :(得分:1)

你必须使用&amp;而不是普通&amp ;.它是一个html实体。

<li><a href="index.php?c=tutorials&amp;p=cat&amp;cid=1" >LINK</a></li>

答案 3 :(得分:0)

是的,正如其他人在上面发布的那样,你需要将你的amparsands作为&amp; amp;而不是&amp;。

<li><a href="index.php?c=tutorials&amp;p=cat&amp;cid=1">LINK</a></li>

应该有用。

答案 4 :(得分:0)

要与 XHTML (以及一般的 XML )兼容,必须转义ampersand 。为此,需要使用SGML/XML entity

有三种不同的实体可用于表示&符号:

  1. 命名实体:&amp; (这是XML规范中定义的五个predefined entities之一。)

  2. 十进制numeric character reference&#38;

  3. 十六进制numeric character reference&#x26;

  4. 因此,示例href属性的值可以用以下三种方式之一表示:

    href="index.php?c=tutorials&amp;p=cat&amp;cid=1"
    href="index.php?c=tutorials&#38;p=cat&#38;cid=1"
    href="index.php?c=tutorials&#x26;p=cat&#x26;cid=1"
    

    当然,将上述实体混合起来是有效的:

    href="index.php?c=tutorials&amp;p=cat&#38;cid=1"
                               ^^^^^     ^^^^^
    

    ...但是大多数人都会争论在整个文档(甚至是整个网站)中采用一致的方法。

    在可用于表示&符号的三个实体中,我认为&amp;在XHTML中最常用。

    最后注意事项:在创作 HTML 时,也可​​以使用 之一 ,但browsers today do not require that the ampersand be escaped