0

我有代码可以<%@include file = "/webpages/includeFiles/header.jsp" %>正常工作。

但是我想用它request.getContextPath()

就像是<%@include file = "request.getContextPath ()/webpages/includeFiles/header.jsp" %>

我得到一个编译错误。

我怎样才能实现它?

4

2 回答 2

1

您不能在 中包含动态值<%@include file = "">

使用接受动态值的标准动作<jsp:include page="<%=request.getContextPath()%>/firstPage.jsp"></jsp:include>

于 2013-09-12T10:12:05.150 回答
0

不要使用静态包含,而是尝试使用动态包含

<jsp:include page='<%= request.getContentType()/webpages/includeFiles/header.jsp %>' />

我没有测试过,如果不起作用,请尝试操作位。

您可以在这里查看:Include file from dynamic property value

于 2013-09-12T10:21:21.403 回答