I'm using a fancybox to work with images in my Java Web Application. Here is some code of 开发者_JAVA技巧my.jsp:
<c:forEach var="imageName" items="${requestScope.myCollection.imageNames}">
<a rel="image_group" href="/My_War/large/${imageName}.do" title="${imageName}"><img alt="" src="/My_War/small/${imageName}.do" /></a>
</c:forEach>
And here is one of functions of my spring image controller, that writes images as byte stream:
@ExceptionHandler(IOException.class)
@RequestMapping(value = "/large/{name}.do", method = RequestMethod.GET)
protected void getLargeImage(@PathVariable("name") String name, OutputStream outStream) throws IOException{
//here I read an image as byte stream and write it into output stream
outStream.write(Utils.readImageFromFolder(name, false));
outStream.flush();
outStream.close();
}
So I have a difficult with maximazing an image. Small images load correct, but when I click on them it show me garbage. I understand, that it should be a link to real image at my jsp, not to image controller. So how can I solve this problem? Help please:)
I found the solution; it's so simple:) Just add property: 'type' : 'image' to fancybox config)))
Fancybox is missing the type of the request since you are pointing to a .jsp page, and then it is autodetecting it as Ajax.
Append a dummy parameter &type=.jpg or png or whatever it is to the end of the URL or as you said set 'type':'image'.
Cheers!
精彩评论