我有一个使用Jsp页面的动态Web项目。我有一个类Product,它有一个getProductImage()方法,该方法返回存储在MySql数据库中的每个产品的图像url。
在我的jsp文件中,我尝试上传图片两次第一次是使用它自己的url,第二次是方法返回的url。
相关代码:
<% for(Product u : list)
{ %>
<a><img alt="Poza1" style="width: 270px; height: 180px;" src="<% u.getProductImage();%>"></a>
<a><img alt="Poza2" style="width: 270px; height: 180px;"src="./images/1.jpg"></a> <br>
Nume Produs: <%= u.getProductName()%><br>
Stoc produs: <%= u.getProductStock()%><br>
Imagine: "<%= u.getProductImage()%>"<br>
<%} %> `

正如您所看到的,我在上传的图像的最后一行打印了该方法返回的内容。为什么我的图片不能通过方法中的url上传?
发布于 2017-01-11 21:07:19
Jozef Chocholacek发现并解决了这个问题:
You are missing = in src attribute of the first image. I.e. src="<% u.getProductImage();%>"
has to be src="<%= u.getProductImage() %>" (as in the last line).
If you checked the generated code, you should see it.谢谢你,Jozef!
https://stackoverflow.com/questions/41588901
复制相似问题