JSP无法在Tomcat中正确呈现 [英] JSP not rendering properly in Tomcat

查看:131
本文介绍了JSP无法在Tomcat中正确呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Tomcat中运行的JSP页面无法正确呈现。以下是helloworld.jsp的样子:

I have a JSP page running in Tomcat that is not rendering properly. Here is what helloworld.jsp looks like:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="cms-taglib" prefix="cms" %>
<html>
  <head>
    <title>${content.title}</title>
  </head>
  <body>
    <cms:mainBar
       dialog="my-page-properties-dialog"
       label="Page Properties"
       adminButtonVisible="true"/>
    <h1>${content.title}</h1>
    <p>Hello Magnolia World !</p>

    Current time: <%= new java.util.Date() %>
    <%-- JSP Comment --%>

  </body>
</html>

,最终输出如下:

<%@ page
contentType =text / html; charset = UTF-8
language =java%><%@ taglib
uri =cms-taglibprefix =cms%> Hello
Magnolia World!

<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="cms-taglib" prefix="cms" %> Hello Magnolia World!

Hello Magnolia World!当前时间:
<%= new java.util.Date()%><% - JSP
评论 - %>

Hello Magnolia World ! Current time: <%= new java.util.Date() %> <%-- JSP Comment --%>

简而言之,看起来只有表达式$ {content.title}被评估并呈现得很好,但其他所有内容如页面指令,其他JSP表达式和JSP注释都没有。

In short, it seems like only the expression ${content.title} is evaluated and rendered fine but everything else like the page directives, other JSP expressions and JSP comments are not.

我正在使用Tomcat附带的CMS,但分发的JSP模板样本似乎很好。我想我上面写的代码有点不对。

I'm using a CMS that comes with Tomcat but the JSP templates samples from the distribution seem fine. I suppose it's something wrong from the code I written above.

更新:我修复了日期表达式和注释的关闭标记。但是,页面指令未被解析。

Update: I've fixed the closed tag for the date expression and the comment. However, the page directives aren't being parsed.

推荐答案

我发现了问题。这是我的一个愚蠢的错误。即使我修复了正确的JSP语法并使用了jsp扩展,我还是要告诉CMS引擎将这个模板显式地呈现为JSP。感谢大家抓住我的语法错误。我想在使用其他框架时要注意这一点。

I found the problem. It's a stupid mistake on my end. Even though I fixed the correct JSP syntax and had the jsp extension, I needed to tell the CMS engine to explicitly render that one template as JSP. Thanks everyone for catching my syntax error though. I suppose it's something to watch out for when working with other frameworks.

这篇关于JSP无法在Tomcat中正确呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆