我所拥有的任何地方:
<img alt="image" src="<%=request.getContextPath()%>/images/image.png" >
NetBeans报告错误:
Bad value " /images/image.png" for attribute "src" on element "img": WHITESPACE in PATH.
Syntax of IRI reference:
Any URL. For example: '/hello', '#canvas', or 'http://example.org/'. Characters should be represented in NFC and spaces should be escaped as '%20'.
From line 42, column 21; to line 42, column 64
(Rule Category: Attributes)
我怎样摆脱它?
答案 0 :(得分:1)
不要在JSP文件中使用Java代码。使用JSTL。您可以使用以下代码获取上下文路径
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
${pageContext.servletContext.contextPath}
// OR
${pageContext.request.contextPath}