我在 jsp 页面中设置上下文路径,但在运行 jsp 页面时显示错误。
如下所示。
<c:set var="path" value="${pageContext.request.contextPath}"/>
<% urlName='<c:out value="${path}"/>/tran/handleTransactionResults.do'; %>
${path} 没有显示上下文路径。
我在 jsp 页面中设置上下文路径,但在运行 jsp 页面时显示错误。
如下所示。
<c:set var="path" value="${pageContext.request.contextPath}"/>
<% urlName='<c:out value="${path}"/>/tran/handleTransactionResults.do'; %>
${path} 没有显示上下文路径。
您不能在 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"; %>