繁体   English   中英

将一个JSP页面包含到另一个页面中

[英]Including one JSP page into another

我有一个包含另一个HTML页面的JSP页面。 后者具有以下内容:

<html>
<body>
<ul>    

<li>
<a href="/TutorWebApp/page/common/login.jsp">${startPage}</a>
</li>            

</ul>
</body>
</html>

该html文件是xml的xslt转换结果

<?xml version="1.0" encoding="UTF-8"?>
<testing>
    <menu>
        <menu-item>
            <title>${startPage}</title>
            <url>/TutorWebApp/page/common/login.jsp</url>                        
        </menu-item>
    </menu>
</testing>

以及帮助样式表

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">   

    <xsl:template match="/">
        <html>            
            <body>                
                <ul>
                    <xsl:apply-templates/>
                </ul>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="menu-item">
        <li>
            <a>
                <xsl:attribute name="href">
                    <xsl:value-of select="url"/>
                </xsl:attribute>
                <xsl:value-of select="title"/>
            </a>            
        </li>        
    </xsl:template> 
</xsl:stylesheet>

我通过使用JSTL的c:import标签来包含HTML页面(我使用jspf -header和footer,并且库包含在header中)。

<fmt:bundle basename="by.epam.testing.resource.content" prefix="content.">
    <fmt:message key="inputinfo" var="InputInfo"/>    
    <fmt:message key="exit" var="Exit"/>   
    <fmt:message key="startPage" var="StartPage"/>
</fmt:bundle>
<div class="left"> 
    <c:if test="${role eq 'Tutor'}">
        <c:import url="/page/menuForTutor.html" charEncoding="UTF-8"/>
    </c:if>

    <c:if test="${role eq 'Student'}">
        <c:import url="/page/menuForStudent.html" charEncoding="UTF-8"/>
    </c:if>    
</div>

问题是我得到以下输出。 即,JSP变量名称未扩展。 截图

有什么办法解决这个问题? 谢谢。

引用JB Nizet的评论:

HTML文件是静态文件,JSP编译器不解释。

您不能在HTML文件中使用JSP EL。

而且,另一个HTML页面中的完整HTML页面是无效的HTML。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM