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

Posted 缘来狠狂

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了According to TLD or attribute directive in tag file, attribute value does not accept any expressions相关的知识,希望对你有一定的参考价值。

在运用标准标签库和EL表达式写JSP页面的时候,有时候会报500错误

 

 

执行某jsp页面时,弹出如标题所示异常,jsp代码如下:

<%@ 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+"/";
%>

<!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>

异常的原因是不能识别“${userInfo}”,解决办法有两种:
一、在page指令里,加入isELIgnored="true"属性,即
<%@ page language="java" contentType="text/html;charset=gbk"  isELIgnored="true" %>
二、把<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>变为:
<%@ taglib prefix="c" uri=http://java.sun.com/jstl/core_rt  %>
经过改动之后,jsp页面能正常执行了。

以上是关于According to TLD or attribute directive in tag file, attribute value does not accept any expressions的主要内容,如果未能解决你的问题,请参考以下文章

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

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

jstl 中无法使用EL语句。异常信息:According to TLD or attribute directive in tag file, attribute value does not ac

Attribute class invalid for tag present according to TLD

Struts的莫名问题解决方法:Attribute class invalid for tag present according to TLD

English - according to 的用法说明