前言
jsp页面使用表达式<%=basePath%>跳转报“org.apache.jasper.JasperException: /jsp/login/welcome.jsp (line: 26, column: 27) attribute for %>" is not properly terminated”错误,具体如下:
welcom.jsp
<body>
<jsp:include page="<%=basePath%>common/header.jsp"></jsp:include>
</body>
错误信息
严重: Servlet.service() for servlet [jsp] in context with path [/pm] threw exception [/jsp/login/welcome.jsp (line: 26, column: 27) attribute for %>" is not properly terminated] with root cause
org.apache.jasper.JasperException: /jsp/login/welcome.jsp (line: 26, column: 27) attribute for %>" is not properly terminated
正确写法
<body>
<jsp:include page="../common/header.jsp"></jsp:include>
</body>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<jsp:include>标签允许包含动态和静态页面,其中page属性:page="{relativeURL | <%= expression %>}"可以使用绝对路径或者相对路径。
总结
The End。