自动在每个 JSP 中包含一个 JSP

发布于 2024-07-29 21:21:08 字数 805 浏览 2 评论 0原文

我想通过透明地包含它们来进一步简化我的 JSP。 例如,这是我要删除的行:

<%@ include file="/jsp/common/include.jsp"%>

include.jsp 文件基本上声明了我正在使用的所有标记库。 我正在 WebSphere 6.0.2 上运行它,我相信并且已经尝试过此配置:

<!--    Include this for every JSP page so we can strip an extra line from the JSP  -->
    <jsp-config>
        <jsp-property-group>
            <url-pattern>*.htm</url-pattern>
            <!--<include-prelude>/jsp/common/include.jsp</include-prelude>-->
            <include-coda>/jsp/common/include.jsp</include-coda>
        </jsp-property-group>
    </jsp-config>

include-preludeinclude-coda 都不起作用。

我读到其他 WebSphere 用户无法启动并运行它; 然而,tomcat 用户却可以。

I would like to simplify my JSP's even further by transparently including them. For instance, this is the line I would like to remove:

<%@ include file="/jsp/common/include.jsp"%>

The include.jsp file basically declares all the tag libraries I am using. I am running this on WebSphere 6.0.2 I believe and have already tried this configuration:

<!--    Include this for every JSP page so we can strip an extra line from the JSP  -->
    <jsp-config>
        <jsp-property-group>
            <url-pattern>*.htm</url-pattern>
            <!--<include-prelude>/jsp/common/include.jsp</include-prelude>-->
            <include-coda>/jsp/common/include.jsp</include-coda>
        </jsp-property-group>
    </jsp-config>

Both the include-prelude and include-coda did not work.

I was reading that other WebSphere users were not able to get this up and running; however, tomcat users were able to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只有一腔孤勇 2024-08-05 21:22:00

您可以尝试编写一个调用的过滤器

getRequestDispatch( "path-to-jsp-to-include" ).include( req, res )

You could try writing a Filter that calls

getRequestDispatch( "path-to-jsp-to-include" ).include( req, res )
我是有多爱你 2024-08-05 21:21:50

我不确定这是哪个版本的 Servlet 规范引入的...Websphere 的 servlet 容器是否可能不支持它?

不管怎样,对于此类任务,有一个更好的第三方工具,称为 SiteMesh。 它允许您完全按照您所描述的方式撰写页面,但方式非常灵活。 受到推崇的。

I'm not sure which version of the Servlet spec this was introduced... is it possible that Websphere's servlet container doesn't support it?

Either way, for this sort of task there's a much nicer 3rd-party tool called SiteMesh. It allows you to compose pages in exactly the sort of way you describe, but in a very flexible way. Recommended.

玉环 2024-08-05 21:21:38

jsp-property-group 是在 JSP 2.0 (iow Servlet 2.4) 中引入的。 Websphere 6.0 是 Servlet 2.3。

所以你有3个选择:

  1. 忘记它。
  2. 升级 Websphere。
  3. 替换 Websphere。

The jsp-property-group was introduced in JSP 2.0 (i.o.w. Servlet 2.4). Websphere 6.0 is Servlet 2.3.

So you have 3 options:

  1. Forget it.
  2. Upgrade Websphere.
  3. Replace Websphere.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文