0

我在 jsp 页面中设置上下文路径,但在运行 jsp 页面时显示错误。

如下所示。

<c:set var="path" value="${pageContext.request.contextPath}"/>

<% urlName='<c:out value="${path}"/>/tran/handleTransactionResults.do'; %>

${path} 没有显示上下文路径。

4

1 回答 1

3

您不能在 scriptlet 中使用 JSP 标记。像这样做:

<c:set var="path" value="${pageContext.request.contextPath}"/>
<% urlName= request.getAttribute("path") + "/tran/handleTransactionResults.do"; %>

或者更简单:

<% urlName= request.getContextPath() + "/tran/handleTransactionResults.do"; %>

如果你只是想输出你的路径,你可以使用<%= %>快捷方式:

<%= request.getContextPath() + "/tran/handleTransactionResults.do"; %>
于 2011-10-31T09:44:31.027 回答