JSP中使用JSTL表达式

JSP中使用JSTL表达式

  最近写web项目,为了使JSP代码美观好维护,决定采用EL&JSTL表达式。

    EL表达式直接就可以用,但是JSTL表达式是属于apache的一个开源库,这个用起来就需要倒入一些jar包之类。网上的方法大多雷同,最重要的都是几年前的东西了,所以游戏要自己整理一下。

正文

https://tomcat.apache.org/download-taglibs.cgi

下载页面有4个jar包:

Impl: taglibs-standard-impl-1.2.5.jar JSTL实现类库

Spec: taglibs-standard-spec-1.2.5.jar JSTL标准接口

EL: taglibs-standard-jstlel-1.2.5.jar JSTL1.0标签-EL相关

Compat: taglibs-standard-compat-1.2.5.jar 兼容版本

查看README文档说明

https://www.apache.org/dist/tomcat/taglibs/taglibs-standard-1.2.5/README_bin.txt

发现有这么一句话:

If you do not use JSTL 1.0 tags then the "taglibs-standard-jstlel" JAR may be
omitted. If you do not use the XML library, then the Apache Xalan dependencies
may also be omitted.

 大意就是如果不用JSTL1.0版本的话,那么第三个EL jar包就没必要添加。实际应用中,一般添加前两个库就可以。

 直接导入到Web-content目录下的WEB-INF中的lib文件夹

 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  导入JSTL核心库,其他格式化之类的库同理

posted @ 2018-03-23 11:08 朝阳的自留地 阅读( ...) 评论( ...) 编辑 收藏

猜你喜欢

转载自blog.csdn.net/e5yrt2/article/details/86175720
今日推荐