---
title: " attribute value does not accept any expressions"
author: "李雨泽"
date: "2014-03-18T10:03:09Z"
tags: []
categories: ["编程语言"]
slug: "attribute-value-does-not-accept-any-expressions"
draft: false
lastmod: "2014-03-18T10:09:43Z"
id: 2032668
url: "https://lichunhui.iteye.com/blog/2032668"
---

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

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

&lt;%@ page language="java" contentType="text/html;charset=gbk" %&gt;  
&lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %&gt;  
&lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %&gt;   
&lt;%  
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
%&gt;

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;  
&lt;html&gt;  
  &lt;head&gt;  
    &lt;base href="&lt;%=basePath%&gt;"&gt;  
  &lt;/head&gt;  
    
  &lt;body&gt;  
    This is the result:  
    &lt;c:out value="${userInfo}" default="没有结果"/&gt;  
  &lt;/body&gt;  
&lt;/html&gt;

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