執行某jsp頁面時,彈出如標題所示異常,jsp代碼以下:html
<%@ page language="java" contentType="text/html;charset=gbk" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>java
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
</head>
<body>
This is the result:
<c:out value="${userInfo}" default="沒有結果"/>
</body>
</html>express
異常的緣由是不能識別「${userInfo}」,解決辦法有兩種:
1、在page指令裏,加入isELIgnored="true"屬性,即
<%@ page language="java" contentType="text/html;charset=gbk" isELIgnored="true" %>
2、把<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>變爲:
<%@ taglib prefix="c" uri=http://java.sun.com/jstl/core_rt %>
通過改動以後,jsp頁面能正常執行了。jsp
正解:若是頁面不能識別EL表達式,頁頁上會直接原樣輸出你寫的EL表達式,這時使用方法1便可,第二種狀況就跟tld有關了,必須與你的jstl.jar包定義的tld相一致,這時若是遇到「According to TLD or attribute directive in tag file, attribute value does not accept any expressions」這種異常,你能夠打開本身的jstl.jar看一下它的meta-inf下相關的tld文件是如何定義相關標籤的,通常都是引用prefix時出錯,版本緣由。post