<tr><th>s.no</th>
<th>File name</th>
<th>Date and time</th>
<th>Show</th></tr>
<%
while(rs.next()){
String id=rs.getString(1);
String name=rs.getString(2);
String date=rs.getString(3);
try{
File file=new File("C:\\Users\\Ragulprasath\\Desktop\\Register\\src\\main\\webapp\\uploaded\\" name);
if(file.exists()){
//what should put here
}
else{
//also here
}
}
catch(Exception e){}
%>
<tr>
<td><%=id%></td>
<td><%=name%></td>
<td><%=date%></td>
<td><input type="button" onClick="location.href='view.jsp?msg=<%=name%>'" value="View the contents"/></td>
</tr>
<%}
%>
我該如何根據檔案是否存在(綠色)來設定行的顏色,如果不存在,則行應該是紅色的。在此我正在獲取檔案名等詳細資訊并檢查它是否存在但我不知道進一步進行
uj5u.com熱心網友回復:
我真的不知道任何 JSP 但無論語言是什么,你都應該在你的 IF/ELSE 塊中設定你想要的顏色(如果你在這段時間里,不要認為你真的需要 ELSE)
// ....
While (rs.next()) {
String bgColor = "#00000";
// ....
if(file.exists()){
bgColor = "#FFFF"
}
<tr style="background-color:<% bgColor %>;">
// ....
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/479240.html
標籤:javascript html jsp
上一篇:如何根據傳遞的引數在javascript函式中命名匿名函式?[復制]
下一篇:在導航欄中使用帶有文本的影像
