我写的实体类, 在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>
< } %>
其中图片的位置没问题,但图片显示不出来
解决方案 »
- 请各位同事,帮忙呀。版主帮忙,本人竞选十大杰出青年,帮投票呀
- java.lang.NoSuchMethodException
- $$$$$$请问JAVA中怎么才能把图标拖入界面,自动读取文件的路径
- 没份了。。。。。但是还没法入门
- 问一个关于JRadioButton和JTextField的问题?
- tomcat启动时出错!高手帮忙
- 谁有JAVA编程思想第三版习题的答案?
- 在java程序运行时,如何隐藏命令提示符窗口
- 谁用过jbuilder7-->Wizards-->Native Executable Builder 功能!?
- 有木有在项目中遇到代码表这个概念的?
- 征题
- static 该在什么情况下如何使用?
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是否正确,是不是有空格什么的