【问题标题】:html can't get photo with a correct address return 404html 无法获取地址正确的照片返回 404
【发布时间】:2021-02-11 04:07:36
【问题描述】:

所以我使用 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。

那为什么?

【问题讨论】:

  • 404 说它不正确,不管“谁”同意什么是正确的。

标签: javascript java html web http-status-code-404


【解决方案1】:

在您的 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>

【讨论】:

  • 你是否在你的.jsp文件中添加java.sun.com/jsp/jstl/core" prefix="c" %>,你的文件必须是.jsp
猜你喜欢
  • 2011-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 1970-01-01
  • 1970-01-01
  • 2020-05-27
相关资源
最近更新 更多