我在我的控制器中得到了这个:
@RequestMapping(value = "details", method = RequestMethod.GET)
public ModelAndView details(@Valid @ModelAttribute("MessageForm") final MessageForm form, @RequestParam("publicationid") String publicationid) {
final Publication pub = ps.findById(Integer.valueOf(publicationid));
final User user = us.findById(pub.getUserid());
final ModelAndView mav = new ModelAndView("details");
long myid = pub.getPublicationid();
UploadFile ufa = imageServiceImp.findFirstById(Long.parseLong(publicationid));
System.out.println("mi publication id es " +ufa.getPublicationId());
System.out.println("mi id de upload es " + ufa.getId());
System.out.println("mis bytes son " + ufa.getData().toString());
// these prints work fine
try {
Image img = ImageIO.read(new ByteArrayInputStream(ufa.getData()));
mav.addObject("image1", img);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//other stuff
return mav;
}
所以我在我的 JSP 中做了以下内容来显示图像:
<img class="mySlides" src="<c:out value="${image1}" />" >
结果当我进入这个页面尝试我的程序时收到以下消息(图像当然不显示):
Sep 26, 2018 11:27:23 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/null/meinHaus/BufferedImage@4c8d98b4:%20type%20=%205%20ColorModel:%20] in DispatcherServlet with name 'dispatcher'
会发生什么?
我正在使用 spring-mvc。
getData() 也返回一个 byte[] 类型的数组。
临摹微笑
相关分类