写在前面:JSTL是jsp的标准标签库,它封装了JSP应用的通用核心功能。
详细介绍查看 菜鸟教程
-
引入jar包,在pom.xml文件中添加:
<!-- https://mvnrepository.com/artifact/jstl/jstl --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version>
-
在jsp文件中添加:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-
在 web.xml中替换,原先2.3版本不支持jstl:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>Archetype Created Web Application</display-name> </web-app>