According to TLD or attribute directive in tag file, attribute value does not accept any expressions

执行某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

相关文章
相关标签/搜索