jsp读SQL数据库信息并逐条向上滚动公告显示
发布网友
发布时间:2022-05-24 14:20
我来回答
共1个回答
热心网友
时间:2023-11-07 20:27
<table
width="250"
id="mytalbe"
style="background:
url('images/b.gif')
">
<%
WebApplicationContext
wac
=
WebApplicationContextUtils
.getWebApplicationContext(this.getServletContext());
INoticeboardService<Noticeboard>
noticeboardSer
=
(INoticeboardService)
wac
.getBean("noticeboardService");
List<Noticeboard>
noticeboradList
=
noticeboardSer
.list("From
Noticeboard
as
n
order
by
id
desc");
//此处你取出的是
第1条数据
所以只显示一条,显示多条
应该将此注释
//Noticeboard
nb
=
noticeboradList.get(0);
%>
<tr>
<td>
<marquee
direction="up"
height="300"
onmouseout="this.start()"
onMouseOver="this.stop()"
scrollamount="2">
<%
//循环将消息显示
for(int
i=0;i<noticeboradList.size();i++){
Noticeboard
nb
=
noticeboradList.get(i);
%>
<%=nb.getContent()%>
<br/>
<%
}
%>
</marquee>
</td>
</tr>
</table>