我写的实体类, 在jsp能把图片的位置显示出来 ,但图片显示不出来,望高手赐教 在线等 实体类代码public class AdlistArraylist {
private Connection conn = null;
private List list = new ArrayList();
private BaseDBConnection db = new BaseDBConnection();
private PreparedStatement pstm = null;
private ResultSet rs = null;
public List getPath(int type){
String sql = "select path from adlist where type="+type;
//String s = "select path from adlist where type = "+type+" order by id";
conn = db.getConn();
try {
pstm = conn.prepareStatement(sql);
rs = pstm.executeQuery();
while(rs.next()){
list.add(rs);
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
return list;
}
}jsp代码
<%
AdlistArraylist a = new AdlistArraylist();
List list = a.getPath(10);
%>
<%
for(int i = 0;i<list.size();i++){
%>
<table width="200" border="0" cellspacing="0" cellpadding="0" class="gg">
<tr>
<td align="center"><img src="images/<%=list.get(i) %>" width="191" height="87" border="0" /></td>
</tr>
</table>
< } %>
其中图片的位置没问题,但图片显示不出来
private Connection conn = null;
private List list = new ArrayList();
private BaseDBConnection db = new BaseDBConnection();
private PreparedStatement pstm = null;
private ResultSet rs = null;
public List getPath(int type){
String sql = "select path from adlist where type="+type;
//String s = "select path from adlist where type = "+type+" order by id";
conn = db.getConn();
try {
pstm = conn.prepareStatement(sql);
rs = pstm.executeQuery();
while(rs.next()){
list.add(rs);
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
return list;
}
}jsp代码
<%
AdlistArraylist a = new AdlistArraylist();
List list = a.getPath(10);
%>
<%
for(int i = 0;i<list.size();i++){
%>
<table width="200" border="0" cellspacing="0" cellpadding="0" class="gg">
<tr>
<td align="center"><img src="images/<%=list.get(i) %>" width="191" height="87" border="0" /></td>
</tr>
</table>
< } %>
其中图片的位置没问题,但图片显示不出来
List list = a.getPath(10);
建议LZ使用JavaBean声明或者传值,或者你可以把java代码放到jsp文件中,试一下,检查具体问题
如果把代码放到jsp中能显示的话,就是服务器传值的问题,如果不能显示,就是代码问题了
AdlistArraylist a = new AdlistArraylist();
List list = a.getPath(10);
%>
现在我的这段代码就在jsp里面的 数据库里面有3张图片 能显示 但是看到的是十叉
<%=list.get(i) %>取出的是什么东东,你自己看看吧
还有你在这个页面生成后,查看下HTML代码,看SRC是否正确,是不是有空格什么的