我正在尝试将gridview中按钮的值动态更新为计数值。现在,我在“out.println("<td>" + "<input type = button id = getid onclick=getbuttonid() value = "<%=count%>" + ">" + "</td>");
处获得Unclosed String文字错误。我的目标是将count的值指定为按钮值。我做错了什么?
<tr>
<td colspan=4 align="center"
style="background-color:teal">
<b>User Record</b></td>
</tr>
<tr style="background-color:lightgrey;">
<td><b>Record Number: </b></td>
<td><b>Card Number: </b></td>
<td><b>MiddleName:</b></td>
<td><b>BankAccountID:</b></td>
<td><b>CurrencyID:</b></td>
<td><b>DayTransactionLimit:</b></td>
<td><b>Select:</b></td>
</tr>
<%
if(request.getParameter("mobilenumber")!=null)
{
FileReader fr = new FileReader(new File(("C:\\Users\\Farheen\\Documents\\NetBeansProjects\\Demo\\records.txt")));
BufferedReader br = new BufferedReader(fr);
String line = null;
int count =0;
// out.println("<table>");
while((line = br.readLine()) != null){
//out.print(line + "<br/>");
out.println("<tr>");
String[] data = line.split("\t");
for (String val : data) {
out.println("<td>" + val + "</td>");
count ++;
}
out.println("<td>" + "<input type = button id = getid onclick=getbuttonid() value = "<%=count%>" + ">" + "</td>");
out.println("</tr>" );
}
// out.println("");
br.close();
}
%>
答案 0 :(得分:1)
正如我在answer中写到的另一个问题,不要使用Java代码生成HTML输出。正如您所看到的,非常容易出错。
无论如何,如果你坚持,那就用
out.println("<td><input type =\"button\" id=\"getid\" onclick=\"getbuttonid()\" value=\"" + count + "\"></td>");
答案 1 :(得分:0)
更改
out.println("<td>" + "<input type = button id = getid onclick=getbuttonid() value = "<%=count%>" + ">" + "</td>");
到
out.println("<td>" + "<input type = button id = getid onclick=getbuttonid() value = "+ "<%=count%>" + ">" + "</td>");