HTML 无法获取具有正确地址的照片返回 404



所以我使用spring和tomcat,它们在我的/opt/webapps/images/xxxx.jpeg中存在一张照片,在我的html页面中,我想通过我们同意的<img src="/opt/webapps/images/xxxx.jpeg" id="imgProfile" style="width: 150px; height: 150px" class="img-thumbnail" />被更正了,但它总是返回404。

那为什么呢?

在web.xml配置中添加:

<mvc:resources mapping="/resources/**" location="/opt/webapps/images/**" />

在您的jsp页面中:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
</head>
<body>
<link href="<c:url value="/resources/xxxx.jpeg" />" >
</body>
</html>

最新更新