简体   繁体   English

无法在 JSP 页面中显示图像

[英]Unable to display image in JSP page

Hi i am getting path of the image in REST API call as below嗨,我正在 REST API 调用中获取图像的路径,如下所示

<hotel-info:thumb-nail-image>/4014/40140/images/Result_tn.jpg</hotel-info:thumb-nail-image>

How to display image in JSP page ?如何在 JSP 页面中显示图像?

In JAXB class :在 JAXB 类中:

@XmlElement(name = "thumb-nail-image", required = true)
protected String thumbNailImage;

In JSP :在 JSP 中:

<img src="data:image/jpg;base64,${hotelFareResult.basicInfo.thumbNailImage}" alt="Could Not Load Img" width="200" height="200">

Please help me how to display image in JSP ?请帮助我如何在 JSP 中显示图像?

STS project explorer drop downs STS 项目浏览器下拉菜单

Firt of all i am using spring tool suite and i now find solution for displaying image in jsp page.首先,我使用的是 spring 工具套件,现在我找到了在 jsp 页面中显示图像的解决方案。 first you need to have a name.xml file in /webapp/WEB-INF/views/name.xml xml file must be in views folder in WEB-INF and include the content below........首先你需要在/webapp/WEB-INF/views/name.xml 文件中有一个name.xml 文件必须在WEB-INF 的views 文件夹中并且包含下面的内容........

<bean xmlns:mvc="http://www.springframework.org/schema/mvc"
http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
<mvc:resources mapping="/resources/**"
        location="/resources/" /></bean>

........ then place the images folder in the webapp inside the resource folder so that you have access it easily. ........然后将图像文件夹放在资源文件夹内的webapp中,以便您可以轻松访问它。 if you done it properly then add path to place you want like this如果你做得正确,然后添加路径到你想要的地方

<img src="/resources/images/name.png"
                        height="40px" width="55px">

if you have any doubt ...tell me comment如果你有任何疑问...告诉我评论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM