无法在JSP页面中显示图像

时间:2019-01-02 09:35:00

标签: java image rest jsp

嗨,我正在通过REST API调用获取图像的路径,如下所示:

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

如何在JSP页面中显示图像?

在JAXB类中:

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

在JSP中:

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

请帮助我如何在JSP中显示图像?

1 个答案:

答案 0 :(得分:0)

STS project explorer drop downs

我正在使用spring工具套件,现在我找到了在jsp页面中显示图像的解决方案。 首先,您需要在/webapp/WEB-INF/views/name.xml中有一个name.xml文件 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>

... 然后将图像文件夹放在资源文件夹内的webapp中,以便您轻松访问它。 如果操作正确,则将路径添加到您想要的地方

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

如果您有任何疑问...请告诉我

相关问题