[英]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.