无法在 sitemesh内
我正在使用java和sitemesh。
主体装饰器调用一个 Profile.jsp 文件,其中包含一个 jsp 包含,如下所示
<jsp:include page="/serveComments.html" flush="true">
<jsp:param value="78" name="passId"/>
</jsp:include>
但是,当我添加此包含时,profile.jsp 消失,我只留下了serveComments.html(由 sitemesh 处理,因为标头和 boders 位于Decorator.xml
如下
<decorators defaultdir="/WEB-INF/sitemesh-decorators">
<excludes>
<pattern>/j_spring_security_logout</pattern>
<pattern>/pages/logout-redirect.jsp</pattern>
<pattern>*/getMagazine.html*</pattern>
<pattern>*/serveComments.html*</pattern>
</excludes>
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
<decorator name="panel" page="panel.jsp"/>
<decorator name="printable" page="printable.jsp"/>
</decorators>
希望我已经说清楚了。
I'm using java and sitemesh.
the main body decorator calls a Profile.jsp file which has a jsp include as follows
<jsp:include page="/serveComments.html" flush="true">
<jsp:param value="78" name="passId"/>
</jsp:include>
However when I add this include the profile.jsp disappears and I'm just left with the serveComments.html (processed by sitemesh as the header and boders are in place.
The decorator.xml is as follows
<decorators defaultdir="/WEB-INF/sitemesh-decorators">
<excludes>
<pattern>/j_spring_security_logout</pattern>
<pattern>/pages/logout-redirect.jsp</pattern>
<pattern>*/getMagazine.html*</pattern>
<pattern>*/serveComments.html*</pattern>
</excludes>
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
<decorator name="panel" page="panel.jsp"/>
<decorator name="printable" page="printable.jsp"/>
</decorators>
Hope I've made this clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与模板框架一起使用是有问题的。至少在 tomcat 中,jsp:include 标记的实现方式是将输出直接写入输出流,而不是写入 pagecontext 标记缓冲区。我不确定 sitemesh 在幕后是如何工作的,但是 Tiles 作为一个“标准”标签库工作,它将输出写入 pagecontext 标签缓冲区堆栈,然后在渲染整个标签层次结构后将其输出到 servlet 输出流。这使得 jsp:include 在 Tiles 上下文中实际上无法使用。由于 jsp:include 不会写入标记缓冲区,而是直接写入输出流,因此内容将不按顺序发送,或者根本不发送,具体取决于 sitemesh 标记的工作方式。渲染时,sitemesh 标签可能会将输出流重定向到某个空流。
<jsp:include>
is problematic to use with templating frameworks. At least in tomcat, the jsp:include tag is implemented in such a way that it writes the output to the outputstream directly, rather than to the pagecontext tag buffer. I'm not sure how sitemesh works under the hood, but Tiles for instance works as a "standard" tag library, which writes output to the stack of pagecontext tag buffers which are then outputted to the servlet outputstream once the entire tag hierarchy is rendered. This makes jsp:include effectivly unusable in a Tiles context.Since jsp:include doesn't write to the tag buffers but directly to the outputstream, content will be sent out of order, or not at all, depending on how the sitemesh tags work. It could be that the sitemesh tags redirect the outputstream to some null stream while rendering.