在JSP页面上循环显示Action中的集合list,显示不出来,用脚本就能显示出来,为什么 50
action层publicclassSongAction{privateStringsongName;privateStringsinger;privateStringa...
action层
public class SongAction {
private String songName;
private String singer;
private String albumName;
private String fileURL;
private List<Song> songlist;
private String msg;
public String getSongName() {
return songName;
}
public List<Song> getSonglist() {
return songlist;
}
public void setSonglist(List<Song> songlist) {
this.songlist = songlist;
}
public String queryAllSongs()throws Exception{
SongService ss = new SongServiceImpl();
songlist = ss.getSongByAll();
return "success";
}
}
JSP页面
</head>
<body>
<a href="song_add.jsp">添加歌曲</a>
<table border="1" width="600">
<tr>
<td width="10%">歌曲编号:</td>
<td width="10%">歌曲名:</td>
<td width="10%">歌曲URL:</td>
<td width="10%">歌手名:</td>
<td width="10%">专辑名:</td>
</tr>
<%
SongService ss = new SongServiceImpl();
List<Song> li = ss.getSongByAll();
for (Iterator it = li.iterator(); it.hasNext();) {
Object[] obj =(Object[])it.next();
%>
<tr>
<td><%=obj[0] %></td>
<td><%=obj[1] %></td>
<td><%=obj[2] %></td>
<td><%=obj[3] %></td>
<td><%=obj[4] %></td>
</tr>
<%
}
%>
<s:iterator value="songlist" >
<tr>
<td><s:property value="song_id" /></td>
<td><s:property value="songName" /></td>
<td><s:property value="fileURL" /></td>
<td><s:property value="singer" /></td>
<td><s:property value="album" /></td>
</tr>
</s:iterator>
</table>
</body>
</html>
上面的脚本输出就能显示,而下面的标签却显示不出来,为什么呢? 展开
public class SongAction {
private String songName;
private String singer;
private String albumName;
private String fileURL;
private List<Song> songlist;
private String msg;
public String getSongName() {
return songName;
}
public List<Song> getSonglist() {
return songlist;
}
public void setSonglist(List<Song> songlist) {
this.songlist = songlist;
}
public String queryAllSongs()throws Exception{
SongService ss = new SongServiceImpl();
songlist = ss.getSongByAll();
return "success";
}
}
JSP页面
</head>
<body>
<a href="song_add.jsp">添加歌曲</a>
<table border="1" width="600">
<tr>
<td width="10%">歌曲编号:</td>
<td width="10%">歌曲名:</td>
<td width="10%">歌曲URL:</td>
<td width="10%">歌手名:</td>
<td width="10%">专辑名:</td>
</tr>
<%
SongService ss = new SongServiceImpl();
List<Song> li = ss.getSongByAll();
for (Iterator it = li.iterator(); it.hasNext();) {
Object[] obj =(Object[])it.next();
%>
<tr>
<td><%=obj[0] %></td>
<td><%=obj[1] %></td>
<td><%=obj[2] %></td>
<td><%=obj[3] %></td>
<td><%=obj[4] %></td>
</tr>
<%
}
%>
<s:iterator value="songlist" >
<tr>
<td><s:property value="song_id" /></td>
<td><s:property value="songName" /></td>
<td><s:property value="fileURL" /></td>
<td><s:property value="singer" /></td>
<td><s:property value="album" /></td>
</tr>
</s:iterator>
</table>
</body>
</html>
上面的脚本输出就能显示,而下面的标签却显示不出来,为什么呢? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询