在每个JSP中自动包含JSP

10 java websphere jsp

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

<%@ include file="/jsp/common/include.jsp"%>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

无论是include-preludeinclude-coda没有工作.

我读到其他WebSphere用户无法启动并运行; 但是,tomcat用户能够.

Bal*_*usC 8

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

所以你有3个选择:

  1. 算了吧.
  2. 升级Websphere.
  3. 替换Websphere.

  • 我们可能正在升级websphere,但我们永远不会替换它,因为它首先被选择开发.在我开始使用WID/WAS之前,我曾经喜欢IBM产品. (2认同)

ska*_*man 5

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

无论哪种方式,对于这种任务,有一个更好的第三方工具叫做SiteMesh.它允许您以您描述的方式组合页面,但是以非常灵活的方式.推荐的.