【问题标题】:Eclipse shows invalid character or invalid text string or tag not closed properlyEclipse 显示无效字符或无效文本字符串或标记未正确关闭
【发布时间】:2018-04-04 12:57:41
【问题描述】:

Eclipse Neon.3 Release (4.6.3) 在这行代码报错:

<select id="<%=province.id%>" data-placeholder=" " <%=province.multiple%> class="chzn-select" style="margin: 1px auto;width:260px;">
</select>

报告的错误是:

Multiple annotations found at this line:
- Start tag (<select>) not closed properly, expected '>'.
- Invalid character used in text string (<%=province.multiple%> class="chzn-select" style="margin: 1px auto;width:260px;">).
- Invalid text string (<%=province.multiple%> class="chzn-select" style="margin: 1px auto;width:260px;">).

当我从该行中删除 &lt;%=province.multiple%&gt; 时,Eclipse 停止报告这些错误,但据我所知,这是有效代码。它有什么问题?

【问题讨论】:

    标签: java html eclipse jsp jsp-tags


    【解决方案1】:

    应该这样

    &lt;select id="&lt;%=province.id%&gt;" data-placeholder=" " &lt;%=province.multiple%&gt; class="chzn-select" style="margin: 1px auto;width:260px;"&gt;

    是(更新的)

    &lt;select id="&lt;%=province.id%&gt;" data-placeholder=" " multiple="&lt;%=province.multiple%&gt;" class="chzn-select" style="margin: 1px auto;width:260px;"&gt;

    在这种情况下没有必要相关,但也发现了这一点(见详情here):

    在 XHTML 中,属性最小化是被禁止的,并且多个 属性必须定义为 input multiple="multiple"

    那么文件后缀也可能使 Eclipse 更加关键:如果是.xhtml 内容可能必须是.xhtml

    一个好的 - 可能没有直接关系 - 问题:What is the difference between creating JSF pages with .jsp or .xhtml or .jsf extension

    【讨论】:

    • 否,&lt;%=province.multiple%&gt; 回显multiple 属性名称或空字符串以启用或禁用选择多个值:w3schools.com/tags/att_select_multiple.asp
    • 好的,但猜测 Eclipse 会抱怨,因为它在选择标签关闭之前遇到了启动 &lt;,可能是编辑器错误。或者可能不小心插入了隐藏字符。
    猜你喜欢
    • 2012-04-26
    • 1970-01-01
    • 1970-01-01
    • 2016-11-15
    • 1970-01-01
    • 1970-01-01
    • 2018-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多