文件包含不起作用
以下代码在 Netbeans 中引发错误,指出 include 语句未关闭。我尝试过一些类似 @%>
的方法,但我无法弄清楚发生了什么。我在这里做错了什么?
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=request.getAttribute("title")%></title>
</head>
<body>
<%@include file=request.getAttribute("template")%>
</body>
</html>
The below code throws an error in Netbeans saying the include statement is not closed. I've tried a few things like @%>
and I'm not able to figure out what's up. what am I doing wrong here?
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=request.getAttribute("title")%></title>
</head>
<body>
<%@include file=request.getAttribute("template")%>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
>
:根据模板的内容,
也可能有效:Try using
<jsp:directive.include/>
:Depending on the contents of your template,
<jsp:include/>
may also work:include 指令在编译时(翻译时)工作,文件中列出的路径应该相对于 Web 应用程序。
如果想使用更灵活的东西来包含文件时使用jstl标签 < c:导入>
The include directive works at compile time (translation time), the path listed in file should be relative to the web application.
if you want to use something more flexible when used to include files jstl tag < c:import >