开发者

Unable to <jsp:include> within sitemesh <decorator:body />

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 bod开发者_如何学Goers 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.


<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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜