<%@ 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. httpModules与Http模块

    httpModules是往当前应用程序添加HttpModule(http模块)的标签.配置节如下 <httpModules> <add name="ModuleName&q ...

  2. 【C#】分享带等待窗体的任务执行器一枚

    -------------201504161039更新------------- 更新内容: IWaitForm接口删除System.Windows.Forms.DialogResult Dialog ...

  3. EF架构~EF异步改造之路~让DbContextRepository去实现异步接口

    回到目录 返回异步与并行目录 上一讲中,我们定义了三个异步操作接口,这回我们将对它进行实现,而有一个基础知识需要大家清楚,那就是实现接口的方式,一般我们使用默认的方式(隐式实现),这种方法实现的接口方 ...

  4. Suggestion(搜索建议)产品和技术

    今天来简单聊聊Suggestion产品 什么是Suggestion服务? 一图胜千言: 当你想要搜索某个长词语或者一句话输入部分时,Suggestion服务预测你极大可能的候选项,并罗列出来,供你选择 ...

  5. 类型转换及返回json对象的问题

    @ResponseBody @RequestMapping(value="/user/getUserId.do")//method=RequestMethod.POST publi ...

  6. http://www.mysqltutorial.org/python-mysql-query/

    This tutorial shows you how to query data from a MySQL database in Python by using MySQL Connector/P ...

  7. 第 31 章 项目实战-PC端固定布局[1]

    学习要点: 1.准备工作 2.创建项目 3.网站结构 4.CSS选择器 5.完成导航 主讲教师:李炎恢 本章主要开始使用学习用HTML5和CSS3来构建Web页面,第一个项目采用PC端 固定布局来实现 ...

  8. [moka同学笔记]七、Yii2.0课程笔记(魏曦老师教程)[新增管理员,重置密码]

  9. ASP.NET MVC搭建项目后台UI框架—9、服务器端排序

    ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NET M ...

  10. git将本地仓库推送到远程仓库

    如何将本地仓库推送到公司远程仓库? 1:前提是你本地安装好git.先把远程git仓库克隆到本地  git clone 远程仓库的地址(SSH) 2: git  branch //查看本地分支 3: g ...