使用jstl表达式配置

jstl表达式配置

前段与后端动态交换数据用到了el表达式,但el表达式没有流程控制,这时jstl就起到了补充作用,应为他有<c:forEach>,<c:if>等控制语句,但使用jstl语句需要进行三个地方的配置:(这个只为以后忘记了回头来看)

一.web.xml中配置 

<!-- jstl配置 -->
  <jsp-config>
    <taglib>
      <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
      <taglib-location>classpath*:/c.tld</taglib-location>
    </taglib>
  </jsp-config>

二.pom.xml中配置 

在</dependencies>标签里配置如下两个依赖包

<!-- jstl配置信息 -->
		<dependency>
			<groupId>taglibs</groupId>
			<artifactId>standard</artifactId>
			<version>1.1.2</version>
		</dependency>

		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>

三.在你用到jstl语句的jsp文件的头部加上如下信息

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

完成了这三步才能使用jstl语句。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章