这不是单纯由您定义url的方式引起的
index.html(该url不包含
context root):
<img src="/app/images/springboot.png" />
使用相对uri
您应该可以使用相对uri(不使用前导斜杠):
<img src="app/images/springboot.png" />
使用JSP / JSTL:
<img src="${pageContext.request.contextPath}/app/images/springboot.png" />或使用Javascript:
function getContextPath() { return window.location.pathname.substring(0, window.location.pathname.indexOf("/",2));}...var img = new Image();img.src = getContextPath() + "/app/images/springboot.png";document.getElementById('div').appendChild(img);


