包含jsps编译错误
有一个关于包含 jsp 头文件(使用 appengine)的正确方法的快速问题。我有一个 htmlinclude.jsp 只包含 head 部分
这是头文件
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/styles.css" />
<title><%=title%></title>
</head>
<body>
其他 jsp 文件包含此头文件,如下所示
<% String title="page title" ;%>
<%@ include file="htmlinclude.jsp" %>'
在尝试部署到 appengine 时,出现错误 -
SEVERE: Error compiling file: htmlinclude_jsp.java
[javac] Compiling 1 source file
[javac] C:\htmlinclude_jsp.java:46: cannot find symbol
[javac] symbol : variable title
[javac] location: class org.apache.jsp.htmlinclude_jsp
[javac] out.print(title);
[javac] ^
[javac] 1 error
在本地计算机上运行它时,我没有任何问题...是否有我应该设置一个标志,以便 htmlinclude.jsp 不被编译?
Had a quick question on the right way to include jsp header files (using appengine). I have an
htmlinclude.jsp that just contains the head portion
This is the header file
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/styles.css" />
<title><%=title%></title>
</head>
<body>
Other jsp files include this headerfile as follows
<% String title="page title" ;%>
<%@ include file="htmlinclude.jsp" %>'
While trying to deploy to appengine I get an error -
SEVERE: Error compiling file: htmlinclude_jsp.java
[javac] Compiling 1 source file
[javac] C:\htmlinclude_jsp.java:46: cannot find symbol
[javac] symbol : variable title
[javac] location: class org.apache.jsp.htmlinclude_jsp
[javac] out.print(title);
[javac] ^
[javac] 1 error
While running it off of the local machine I have no issues...Is there a flag I should set so the htmlinclude.jsp is not compiled?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从来没有这样做过,但理论上你需要将其声明为全局变量而不是局部变量。您可以使用
<%! 来做到这一点%>
表达式。不过,我猜想您依赖于 JSP 编译器/解析器,无论它是否接受它。
无论如何,这不是“正确的方式”。使用标签库和 EL。
和
I've never done it like that, but in theory you need to declare it as global variable rather than as local variable. You can do that with
<%! %>
expression.I however guess that you're dependent on the JSP compiler/parser whether it eats that or not.
Regardless, this is not the "right way". Use taglibs and EL.
with