我通过在包含页面时传递 参数 来寻求解决方案。
在 master.jsp中
<head> blablabla <c:import url="slave.jsp"> <c:param name="sectionName" value="HEAD" /> </c:import></head><body> blablabla <c:import url="slave.jsp"> </c:import></body>
然后在 slave.jsp 中读取参数,并呈现页面的自定义部分。
<c:choose> <c:when test="${param.sectionName == 'HEAD'}"> head section here [without the <HEAD> tags !] </c:when> <c:otherwise> body section here [without the <BODY> tags !] </c:otherwise></c:choose>不太好看但是可以工作。这样,我就可以删除
HEAD和
BODY部分的重复项。



