无法使用Java代码指定Element的ID

时间:2012-08-20 05:26:29

标签: java html jsp

我从数据库中获取了一些数据,包括每行的id,现在我正在创建一些元素,这些元素的ID必须包含从数据库中获取的ID。

<%
    //Database Codes...I got the rset...
    while (rset.next()) {
%>
<div id="<%=rset.getString(1)%>" class="messageContainer">
</div>
<%
    }
%>

我收到以下错误

Bad value " " for attribute "id" on element "div":An ID must not contain whitespace.
Syntax of id:
An ID consists of at least one character but must not contain whitespace

1 个答案:

答案 0 :(得分:1)

ID需要进行URL编码。