【发布时间】:2012-07-27 16:08:37
【问题描述】:
我在我的 JSP 上使用下面提到的代码:
<%
List eCCategoryList = form.getCategoryList();
//Map<String, String> catNameImgMap = (Map<String, String>) session.getAttribute("catNameImgMap");
Map catNameImgMap = (Map) form.getBlogIdNameMap();
String strImage = "";
Iterator it = eCCategoryList.iterator();
ECircularCategory category = null;
int counter = 0;
while (it.hasNext()) {
category = (ECircularCategory) it.next();
strImage = (String) catNameImgMap.get(category.getName());
%>
strImage 包含我需要在我的 JSP 上显示的图像。我尝试显示如下图像:
<img src="<%=strImage%>" alt="Test Image 1" width="270" height="190"/>
但是上面的代码不起作用,只显示了一个简单的空白,没有别的,我需要在我的 JSP 页面上显示图像,每个图像都存储在 strImage 字符串中,我该怎么做?
请提出建议。
【问题讨论】:
-
请改进代码格式。
-
你是从调用
strImage = (String) catNameImgMap.get(category.getName());获取整个图像数据作为一些编码字符串(如Base64)还是只是图像的名称或图像的URL? -
您能否也粘贴
strImage变量之一的内容? -
只是图像的名称显示在 strImage 字符串中,例如。 m.sears.com/ecircular/SearsLocalAd.jpg 是我通过显示 strImage 得到的字符串。另请告知代码的正确格式。
标签: javascript jsp jstl jsp-tags struts-1