JavaEE-EL表达式的基本使用

news/2024/5/18 13:12:07 标签: jstl, maven, java

文章目录

  • Maven 导入第三方依赖
  • JSP中引入
  • if条件判断
  • for循环输出列表或数组

Maven 导入第三方依赖

<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.source>1.7</maven.compiler.source>
		<maven.compiler.target>1.7</maven.compiler.target>
		<junit.version>4.12</junit.version>
		<spring.version>5.2.5.RELEASE</spring.version>
		<mybatis.version>3.5.4</mybatis.version>
		<mybatis.spring.version>2.0.4</mybatis.spring.version>
		<mysql.version>5.1.48</mysql.version>
		<commons-dbcp.version>2.7.0</commons-dbcp.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>${mybatis.version}</version>
		</dependency>
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>${mybatis.spring.version}</version>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-dbcp2</artifactId>
			<version>${commons-dbcp.version}</version>
		</dependency>
		<dependency>
			<groupId>org.mybatis.generator</groupId>
			<artifactId>mybatis-generator-core</artifactId>
			<version>1.4.0</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		
		<!-- EL表达式的包 -->
		<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>
	</dependencies>

JSP中引入

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<!-- 使用EL表达式 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>

if条件判断

<c:if test="${customer != null}">
			<div>
				<table>
					<tr>
						<td class="show_td">用户ID</td>
						<td class="show_td">用户名</td>
						<td class="show_td">JOBS</td>
						<td class="show_td">PHONE</td>
						<td class="show_td">Operator</td>
					</tr>
					<tr>
						<td class="show_td">${customer.id}</td>
						<td class="show_td">${customer.username}</td>
						<td class="show_td">${customer.jobs}</td>
						<td class="show_td">${customer.phone}</td>
						<td class="show_operator">
							<a href="toUpdateCustomer?id=${customer.id}">UPDATE</a>&nbsp;&nbsp;
							<a href="">DELETE</a>
						</td>
					</tr>
				</table>
			</div>
		</c:if>

在这里插入图片描述

for循环输出列表或数组

<c:if test="${customers != null }">
			
				<div>
					<table>
						<tr>
							<td class="show_td">选择</td>
							<td class="show_td">用户ID</td>
							<td class="show_td">用户名</td>
							<td class="show_td">JOBS</td>
							<td class="show_td">PHONE</td>
							<td class="show_td">Operator</td>
						</tr>
						
						<c:forEach items="${customers}" var="customer">
						
							<tr>
								<td class="show_td"><input name="ids" type="checkbox" value="${customer.id}"></td>
								<td class="show_td">${customer.id}</td>
								<td class="show_td">${customer.username}</td>
								<td class="show_td">${customer.jobs}</td>
								<td class="show_td">${customer.phone}</td>
								<td class="show_operator">
									<a href="toUpdateCustomer?id=${customer.id}">UPDATE</a>&nbsp;
									<a id="deleteCustomer" href="deleteCustomer?id=${customer.id}" onclick="return confirmDelete()">DELETE</a>
								</td>
							</tr>
						
						</c:forEach>
						
						<tr>
							<td colspan="3"  style="text-align: center;"><input type="button" id="deleteButton" value="删除选中项" onclick="deleteCustomers()" ></td>
							<td colspan="3"  style="text-align: center;"><input type="button" value="修改选中项" onclick="updateCustomers()" ></td>
						</tr>
						<tr>
							<td colspan="2"  style="text-align: center;"><a href="pageChange?changePage=-1">上一页</a></td>
							<td colspan="2" style="text-align: center;">${sessionScope.currentPage + 1}&nbsp;&nbsp;/&nbsp;&nbsp;${sessionScope.totalPage}</td>
							<td colspan="2"  style="text-align: center;"><a href="pageChange?changePage=1">下一页</a></td>
						</tr>
						
					</table>
					</form>
				</div>
			</c:if>

在这里插入图片描述


http://www.niftyadmin.cn/n/1261481.html

相关文章

linux安装与配置Hadoop

操作系统&#xff1a;Centos Hadoop&#xff1a;1.1.2 1.安装jdk1.6 输入java -version验证是否安装成功。 vim /etc/profile#set JAVA Enviroment export JAVA_HOME/usr/.../jdk export CLASSPATHCLASSPATH$.:JAVA_HOME/lib export PATH$PATH:JAVA_HOME/ 若新版本java改为系统…

echarts柱状图间距调整_Excel计划与完成数据怎么作图好看?特殊柱状图让数据对比更清晰...

相信大家在制作各类的图表的时候&#xff0c;肯定会碰到一种类型的图表需求&#xff0c;那就是制作我们的一个计划销量和实际完成销量的对比图。简单的柱状图看起来会比较的单调&#xff0c;今天我们就来学习一下如何通过特殊柱状图方式&#xff0c;来展示我们的计划和完成值数…

Android中getLocationOnScreen和getLocationInWindow 获取屏幕大小

需要确定组件在父窗体中的坐标时&#xff0c;使用getLocationInWindow&#xff0c;需要获得组件在整个屏幕的坐标时&#xff0c;使用getLocationOnScreen。 其中location [0]代表x坐标,location [1]代表y坐标。 1 int[] location new int[2] ; 2 3 /**获取在当前窗口内的绝对…

Go协程

本文仅是自己阅读笔记&#xff0c;不正确之处请多包涵和纠正。 原文The way to go 一、什么是协程&#xff1f; 1、进程和多线程 一个应用程序是运行在机器上的一个进程&#xff1b;进程是一个运行在自己内存地址空间里的独立执行体。一个进程由一个或多个操作系统线程组成&a…

Spring依赖注入的单例模式与非单例模式

文章目录Maven Pom.xml文件applicationContext.xml 配置配置单例模式&#xff08;默认模式&#xff09;原型模式注解为Scope("prototype")Maven Pom.xml文件 <properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><…

python class用法理解_如何理解Python中的yield用法?

相信你已经不止一次在函数中看到关键词yield&#xff0c;它起着什么作用&#xff1f;返回什么&#xff1f;和return又有着什么区别呢&#xff1f;这篇文章将会揭开yield的神秘面纱&#xff0c;并给出最浅显易懂的例子。yield关键字做了什么&#xff1f;如果不太好理解yield&…

个人VIM配置实例

用户 vimrc 文件: "$HOME/.vimrc" " vimrc by lewiyonhotmail.com " last update 2013-10-29" 判断操作系统 if (has("win32")||has("win64")||has("win32unix"))let g:isWin1 elselet g:isWin0 endif" --------…

matlab disp函数_简谈matlab的dot命令

在matlab中,dot命令是计算向量或矩阵的内积,在矩阵论中,若a,b是向量,则内积使用表示,其本质是对应元素相乘后再将各项加在一起,即a1b1a2b2…anbn若A,B是2维矩阵,在使用dot计算内积时,matlab把A,B中各列看作向量,分别计算对应列的内积,也可以使用带参数dim的格式,即dot(A,B,dim)…