【发布时间】:2011-03-30 17:28:40
【问题描述】:
我读过: Expression Language in JSP not working 但略有不同。
使用 EL 引用文件可以正常工作,如下所示。
<link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath}/css/global.css"/>
但是,当尝试使用带有 EL 表达式的 JSP 包含标记时:
<jsp:include page="${pageContext.request.contextPath}/header.jsp" />
这会返回 http 500。
org.apache.jasper.JasperException: javax.servlet.ServletException: File "/head_first/header.jsp" not found
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:527)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
我也确保启用 EL。
<%@ page isELIgnored ="false" %>
我的tomcat版本是6.0,web.xml定义JSP是2.5
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
有谁知道为什么 EL 只在 jsp:include 标记中使用时不起作用?
【问题讨论】:
标签: jsp include expression