English 中文(简体)
从MySQL数据库下载图像
原标题:Rendering images from MySQL database

我有以下控制器方法,以成员补贴为基础,在共同财产计划中展示形象:

@RequestMapping(value="/artists/members/photo/{memberId}", method=RequestMethod.GET)
public void renderPhoto(
HttpServletResponse response,
@PathVariable("memberId") Integer memberId)
throws IOException {

   Member member = memberService.loadMember(memberId);
   byte[] photo = member.getPhoto();

   response.setContentType("image/jpeg");
   response.setContentLength(photo.length);
   response.getOutputStream().write(photo);
   response.getOutputStream().flush();

}

对每个成员来说,我要展示他的形象:

<c:forEach items="${members}" var="member">
    <img src="${ctx}/artists/members/photo/<c:out value= ${member.memberId}  />"></img>
</c:forEach>

但破碎的链接图像在浏览器中显示。 我在这里失踪了吗?

问题回答

I m don t really use spring, but I don t see where ${members} is set up. What HTML is being generated?





相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签