0

我有一个包含另一个 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 变量名。 截屏

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

4

1 回答 1

0

引用JB Nizet的评论:

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

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

此外,另一个 HTML 页面中的完整 HTML 页面是无效的 HTML。

于 2014-07-11T16:23:39.467 回答