jsp jstl的使用

1)下载jstl.jar和standard.jar文件,然后将其拷贝到tomcat的lib目录下。
具体的下载地址:http://mirrors.ccs.neu.edu/Apache/dist/jakarta/taglibs/standard/binaries/jakarta-taglibs-standard-1.1.2.zip

2)创建web工程,配置jsp-conifg H) JSP-CONFIG设置JSP页面

3) 在jsp页面中通过JSP taglib引入对应的标签库
如下:
web.xml的版本为2.3
web.xml文件配置(使用该版本的配置出现的问题 EL表达式无法使用):
<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
​
<web-app>
  <display-name>Archetype Created Web Application</display-name>
   <taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>http://java.sun.com/jstl/fn</taglib-uri>
    <taglib-location>/WEB-INF/tld/fn.tld</taglib-location>
  </taglib>
</web-app>

jsp中引入该标签库

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core"  prefix="gs"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
out标签输出信息:
<gs:out value="this is tag Value!"></gs:out>
​
</body>
</html>

web.xml版本2.5
解决EL表达式无法使用的问题

原文地址:https://www.cnblogs.com/ssgao/p/8867390.html