<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<!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>
<!-- 数据源 -->
<sql:setDataSource var="oes"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;DatabaseName=OnlineExaminationSystem"
user="sa" password="123456" /> <!-- 查询语句,result表示数据库信息 -->
<sql:query dataSource="${oes}" var="result">
SELECT * from [Students];
</sql:query> <table border="1" width="100%">
<tr>
<th> ID</th>
<th>Number</th>
<th>Password</th>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>PhoneNumber</th>
<th>Email</th>
<th>Address</th>
<th>ClassInfoId</th>
</tr>
<c:forEach var="row" items="${result.rows}" >
<tr>
<td><c:out value="${row.ID}" /></td>
<td><c:out value="${row.Number}" /></td>
<td><c:out value="${row.Password}" /></td>
<td><c:out value="${row.Name}" /></td> <!-- 格式化输出方式一:使用条件表达式-->
<td><c:out value="${row.Gender==true?\"男\":\"女\" }"/></td> <!-- 格式化输出方式二:使用简单的条件判断标签:c:if c:choose等-->
<%-- <td>
<c:choose>
<c:when test="${row.Gender==true }">
<c:out value="男"/>
</c:when>
<c:otherwise>
<c:out value="女"/>
</c:otherwise>
</c:choose>
</td> --%> <%-- <td><c:out value="${row.Gender}"/></td> --%>
<!-- 格式化输出方式三:先存储值,再获取值进行自定义格式化 -->
<%-- <c:set value="${row.Gender }" var="gender"/>
<td>
<%
if(pageContext.getAttribute("gender").toString()=="true"){
out.println("男");
}else{
out.println("女");
}
%>
</td> --%>
<td><c:out value="${row.Age }"/></td>
<td><c:out value="${row.PhoneNumber }"/></td>
<td><c:out value="${row.Email }"/></td>
<td><c:out value="${row.Address }"/></td>
<td><c:out value="${row.ClassInfoId }"/></td>
</tr>
</c:forEach>
</table> </body>
</html>

jstl中的sql:query标签获取的结果如何格式化输出的更多相关文章

  1. 使用JSTL的sql:query标签制作分页查询遇到NoSuchFieldError: deferredExpression

    参考:http://hi.baidu.com/desyle/item/4fe650265792d7182a0f1c33 症状: 如题所述,代码如下 <sql:query var="re ...

  2. QT-Qt获取当前时间并格式化输出及将积秒转换成时间

    https://blog.csdn.net/u012199908/article/details/50731543 格式化输出当前时刻qDebug()<<"currentTime ...

  3. python中in,not in,比较运算符,格式化输出,编码

    一,python中的in,和not in python中in的作用是检测或查找,例如: c = ‘你好大号胡覅但是啊飞碟说’ b = ‘你好’ print(b in c ) 结果: True c = ...

  4. 在JSP中使用el函数标签获取默认值(男女性别选项)

    http://blog.csdn.net/b10060224/article/details/45771025

  5. 下面哪些属于JSTL中的表达式操作标签。(选择1项)

    A.<c:out> B.<c:if> C.<c:url> D.<c:catch> 解答:A

  6. C++中获取当前时间并格式化输出

    #include <string> #include <time.h> using namespace std; string getTime() { time_t timep ...

  7. thymeleaf获取当前时间并格式化输出

    有时候会需要在模板中直接打印时间的需求,如果输出一个时间还需要在java类中去获取model的话,那未免也太麻烦了,以下为thymeleaf在模板中直接获取时间戳并格式化输的代码 获取时间戳 < ...

  8. Delphi 获取系统时间后格式化输出

    问题:客户现场程序运行提示时间格式不对导致的错误,原因是与开发环境及公司内部测试环境的日期格式不一致: 解决:统一强制转换: //引用单元:SysUtils //目的:实现跨环境兼容不同日期格式,如果 ...

  9. MFC中利用CString和Format成员函数将数字格式化输出

    str.Format("格式控制字符串”,输出列表): 格式控制字符串包括格式字符串和非格式字符串,用双引号括起来.其中非格式字符串原样输出. 格式字符串是以%开头的字符串:%[标识][输出 ...

随机推荐

  1. [PHP]Maximum execution time of 30 seconds exceeded

    前言 在使用PHP渲染页面页面的时候,如果程序处理的时间特别久,超过配置文件(php.ini)设置的超时时间,就会出现如下提示: Maximum execution time of 30 second ...

  2. 谈I/O模型

    一个IO操作涉及两个系统对象: 调用这个IO的用户Process/Thread 系统内核 - System Kernel 一个具体的Read操作包括两个阶段: 内核等待数据准备就绪:Waiting f ...

  3. .NET平台BigO算法复杂度备忘

          之前一篇文章提到BIG O算法复杂度的备忘录, 今天这个是.NET 平台下集合类相关的Big O 算法复杂度   今天先到这儿,希望对您有参考作用, 您可能感兴趣的文章: 数据结构与算法 ...

  4. MySQL的SSL加密连接与性能开销

    本文转载自:http://www.innomysql.net/article/23959.html(只作转载, 不代表本站和博主同意文中观点或证实文中信息) Contents [hide] 1 前言 ...

  5. 程序员用HTML5制作的爱心树表白动画

    体验效果:http://keleyi.com/keleyi/phtml/html5/31.htm 推荐:http://hovertree.com/texiao/css3/18/ HTML代码如下: & ...

  6. JQuery 实现两列等高并自适应高度

    想要使用 JQuery 实现两列等高并自适应高度,其实也很简单,原理就是取得左右两边的高度,然后判断这个值,把大的值赋给小的就行了.看代码: $(document).ready(function() ...

  7. 利用CSS3实现图片无间断轮播图的实现思路

    前言:图片轮播效果现在在各大网站都是非常普遍的,以前我们都是通过postion的left or right来控制dom的移动,这里我要说的是利用css3来制作轮播!相比以前通过postion来移动do ...

  8. HTML 迷宫

    今天补个遗,将很久以前研究 HTML5 的时候写的生成迷宫.迷宫寻路程序整理出来. 下载链接在文章最后. 简介 为什么要做这个 HTML5 迷宫程序?因为我喜欢.我愿意.也是向老程序员学习(见第5节) ...

  9. iOS UIRefreshControl-刷新tableView

    override func viewDidLoad() {        super.viewDidLoad()        refreshControl = UIRefreshControl.in ...

  10. UIButton

    //UIButton->UIControl->UIView //UIControl 带有操作的控件都是继承于它的 //UIButton  实例化  类方法实例化 //实例化时没有位置及大小 ...