JSP 2.1-2.5上用JSTL和EL(表达式语言)的问题
2008-05-16 19:03
423 查看
Preface
在浏览本文之前,请你保证正在使用的是JSP 2.1以上Version,JSP页面上使用到JSTL和EL(表达式语言)。
Introduction
本文主要讲述在JSP 2.1以上Version中使用JSTL时遇到的EL(表达式)问题。
Content
Step 1 - Problem Description
我们通常根据一些书本或者教程的例子去做时往往会出现一些问题,那是因为Java的各种技术在不断更新换代,不少function在不同version上会出现差别或者问题。以下讲述的就是因这样而产生的一个问题。
以我用的JSP 2.5 version来说,以下是一个新创建的JSP页面并且加上了JSTL写的两句语句以用来测试:
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/core" prefix="c"%>
<c:set var="userName" value="ABC"/>
<c:set var="userName2" value="${userName}"/>
<html:html lang="true">
<head>
<html:base />
<title>ELTest.jsp</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This a struts page. <br>
</body>
</html:html>
以上这段代码在我的JSP 2.1 - 2.5 中会产生如下错误信息:
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
Step 2 - Reason
原因很简单,因为这条JSTL的URI在JSP 2.1 Version后已经不适用了。
Step 3 - Solution
解决的办法有几种,我只挑最实际最标准的一种就是更改URI的Link,如下:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
(注意:增加了jsp一层)
在浏览本文之前,请你保证正在使用的是JSP 2.1以上Version,JSP页面上使用到JSTL和EL(表达式语言)。
Introduction
本文主要讲述在JSP 2.1以上Version中使用JSTL时遇到的EL(表达式)问题。
Content
Step 1 - Problem Description
我们通常根据一些书本或者教程的例子去做时往往会出现一些问题,那是因为Java的各种技术在不断更新换代,不少function在不同version上会出现差别或者问题。以下讲述的就是因这样而产生的一个问题。
以我用的JSP 2.5 version来说,以下是一个新创建的JSP页面并且加上了JSTL写的两句语句以用来测试:
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/core" prefix="c"%>
<c:set var="userName" value="ABC"/>
<c:set var="userName2" value="${userName}"/>
<html:html lang="true">
<head>
<html:base />
<title>ELTest.jsp</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This a struts page. <br>
</body>
</html:html>
以上这段代码在我的JSP 2.1 - 2.5 中会产生如下错误信息:
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
Step 2 - Reason
原因很简单,因为这条JSTL的URI在JSP 2.1 Version后已经不适用了。
Step 3 - Solution
解决的办法有几种,我只挑最实际最标准的一种就是更改URI的Link,如下:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
(注意:增加了jsp一层)
相关文章推荐
- jsp表达式语言EL导致的问题
- JSP之EL表达式和JSTL标签库
- 【学习】JSP 2 特性:表达式语言(EL)
- 简述jsp之EL表达式和jstl及其使用
- idea下Maven项目的webapp下的jsp页面无法使用el或者jstl表达式
- JSP之EL表达式和JSTL标签库
- JSTL 入门:表达式语言简化对 JSP 应用的软件维护
- SERVLETJSP Unit05:转发 、 JSP开发常见问题 & Unit09: EL、JSTL
- [Servlet&JSP] 表达式语言EL
- JSTL 表达式与 EL 语言
- JSP中的EL (Express Language表达式语言)
- EL和JSTL表达式语言
- EL(表达式语言 ) jsp2.0新增的功能
- EL(JSP中的表达式语言)
- JSP表达式语言(EL)
- JSP 笔记 —— EL 表达式语言
- jsp版本2.1 servlet版本2.5 el表达式、jstl标签学习以及自定义标签(用标签实现业务逻辑和jsp页面的分离)
- EL语言 与 JSTL表达式
- 实验十三 JSP表达式语言——EL
- Jsp的表达式语言(el)