`
hongfei_sr
  • 浏览: 30010 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

el表达式 jstl 本地tld配置 环境tomcat5.5

阅读更多

 

一、启用EL表达式

 

首先需要两个jar包

 

	jstl.jar 和 standard.jar


如果不涉及jstl就可以直接在jsp头中声明

 

<%@ page isELIgnored="false" %>

  还要检查下web.xml中的声明

 

<web-app id="WebApp_ID" version="2.4"
	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

  其中的version还有2_4.xsd如果是2.5的则要改成2.4,

 

二、使用JSTL

通常情况下我们还要借助于JSTL,结合EL表达式使用

一般网上介绍是这样声明taglib的

 

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

 

 或者

 

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

 

 我暂不清楚这两者有什么区别,但是有些eclipse会提示第二种不合法。

 

但我更喜欢程序和外界没有任何关联,所以在网上搜到让jsp来引用本地的tld文件

1.将下载到的tld文件——例如c.tld放到项目WEB-INF下或建一个目录

2.在项目的web.xml中声明taglib

 

<jsp-config>
	<taglib>
		<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
		<taglib-location>/WEB-INF/c.tld</taglib-location>
	</taglib>
</jsp-config>

 

 3.然后就可以在jsp中这样使用了

 

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

 当然也可以用其他的uri

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics