JSP处理指令未关闭

use*_*206 13 jsp jspinclude include java-ee

我试图在我的JSP中包含一个HTML文件,但是eclipse显示了这个错误

包含的文件

<%@include file="includes/head.html" %>
Run Code Online (Sandbox Code Playgroud)

而错误

Processing instruction not closed
Run Code Online (Sandbox Code Playgroud)

这只是简单的JSP

<%@include file = "includes/head.html" %>

    <form action = "#" method = "POST">
        Username: <input type = "text" name = "username"><br/>
        Password: <input type = "password" name = "password"><br/>
    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Anu*_*shi 60

选择全部,退格,然后按ctrl + z恢复.适合我.但是,熟悉日食的人可能会对这种情况发生的原因有所了解

  • 该死的!它像魅力一样工作.它可能是Eclipse编辑器中的错误吗?这种情况发生在我身上很多时间.代码是正确的,但我仍然想知道我的开始和结束标签.这件烦人的事情只会浪费我不必要的时间. (2认同)

Jai*_*der 11

这看起来很疯狂,但按ctrl + A,ctrl + x,粘贴并保存代码,Bug被清除


Abh*_*mar 0

尝试在@后面留一个空格。

<%@ include file="includes/head.html" %>.
Run Code Online (Sandbox Code Playgroud)

另外,如果 head.html 位于其他目录中,则绝对路径应以 / 或 .. 开头。尝试 <%@ include file="/includes/head.html" %>

<%@ include file="../includes/head.html" %>.
Run Code Online (Sandbox Code Playgroud)