jstl中的sql:query标签获取的结果如何格式化输出
<%@ 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标签获取的结果如何格式化输出的更多相关文章
- 使用JSTL的sql:query标签制作分页查询遇到NoSuchFieldError: deferredExpression
参考:http://hi.baidu.com/desyle/item/4fe650265792d7182a0f1c33 症状: 如题所述,代码如下 <sql:query var="re ...
- QT-Qt获取当前时间并格式化输出及将积秒转换成时间
https://blog.csdn.net/u012199908/article/details/50731543 格式化输出当前时刻qDebug()<<"currentTime ...
- python中in,not in,比较运算符,格式化输出,编码
一,python中的in,和not in python中in的作用是检测或查找,例如: c = ‘你好大号胡覅但是啊飞碟说’ b = ‘你好’ print(b in c ) 结果: True c = ...
- 在JSP中使用el函数标签获取默认值(男女性别选项)
http://blog.csdn.net/b10060224/article/details/45771025
- 下面哪些属于JSTL中的表达式操作标签。(选择1项)
A.<c:out> B.<c:if> C.<c:url> D.<c:catch> 解答:A
- C++中获取当前时间并格式化输出
#include <string> #include <time.h> using namespace std; string getTime() { time_t timep ...
- thymeleaf获取当前时间并格式化输出
有时候会需要在模板中直接打印时间的需求,如果输出一个时间还需要在java类中去获取model的话,那未免也太麻烦了,以下为thymeleaf在模板中直接获取时间戳并格式化输的代码 获取时间戳 < ...
- Delphi 获取系统时间后格式化输出
问题:客户现场程序运行提示时间格式不对导致的错误,原因是与开发环境及公司内部测试环境的日期格式不一致: 解决:统一强制转换: //引用单元:SysUtils //目的:实现跨环境兼容不同日期格式,如果 ...
- MFC中利用CString和Format成员函数将数字格式化输出
str.Format("格式控制字符串”,输出列表): 格式控制字符串包括格式字符串和非格式字符串,用双引号括起来.其中非格式字符串原样输出. 格式字符串是以%开头的字符串:%[标识][输出 ...
随机推荐
- linq分页组合查询
一.linq高级查 1.模糊查(字符串包含) 1 public List<User> Select(string name) 2 { 3 return con.User.Where(r = ...
- [C#] 获取打印机列表
一:获得本地安装的打印机列表 注:(如果在"设备和打印机"中已经添加了局域网的打印机设备,也算是本地安装的打印机:没有添加的则算作局域网打印机) 1,通过 C# 中 Printer ...
- Unity3D 5.x 交互功能 - 碰撞检测函数
1,给第一人称控制器添加脚本:playercollisions.js 脚本中只定义变量,先不添加方法: #pragma strict var door_open_time:float=3.0; var ...
- [moka同学摘录]SQL内联、外联的简单理解
(源自:http://blog.csdn.net/kkk9127/article/details/1487686) --查询分析器中执行:--建表table1,table2:create table ...
- java代码实现队列的优化
package com.voole.queun; /** * @Decription 队列 * @author TMAC-J * */ public class Queun { /** * 初始化队列 ...
- github指令
一般用法 git stash git pull git stash pop 结局冲突 git add . git commit -m "message" git push 查看 g ...
- 如何使用github搭建个人博客
1.去github官网注册个人帐号:没有的:猛戳这里去注册,比如我的账户名:wjf444128852,我的已经汉化(可在github里搜索github如何汉化有插件) 2.点击仓库-新建,仓库名字必须 ...
- jeecg环境搭建20160707
1.首页修改位置:src/main/webapp/webpage/main 2.tomcat45秒超时启动修改,open打开servers项目,在右上角处的timeouts参数修改: 3.eclips ...
- AngularJS在IE8的支持
AngularJS一般不会选择IE8支持, 因为很多特性在IE8下效果很差, 性能也不好, 但是由于项目的需要, 客户的机器有些是XP, 只能够装IE8, 所以为了解决这个, 我查阅了相关的资料,发现 ...
- android SharedPreferences介绍
SharedPreferences是Android平台上一个轻量级的存储类,主要是保存一些常用的配置比如窗口状态,一般在Activity中重载窗口状态onSaveInstanceState保存一般使用 ...