root/trunk/myweb/WebContent/Select.jsp

Revision 20, 1.1 KB (checked in by yabuki, 3 years ago)
  • Property svn:mime-type set to text/plain
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<%@ page language="java" contentType="text/html; charset=UTF-8" %>
3<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
4<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
5
6<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7<html xmlns="http://www.w3.org/1999/xhtml">
8<head>
9<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
10<title>テーブル内容の表示</title>
11</head>
12<body>
13
14<sql:setDataSource
15  var="ds"
16  driver="com.mysql.jdbc.Driver"
17  url="jdbc:mysql://localhost/mydb?characterEncoding=utf8"
18  user="test"
19  password="pass" />
20
21<sql:query var="rs" dataSource="${ds}">
22  SELECT * FROM samples
23</sql:query>
24
25<table>
26<tr><th>id</th><th>sample</th><th>memo</th></tr>
27<c:forEach var="row" items="${rs.rows}">
28  <tr>
29    <td><c:out value="${row.id}" /></td>
30    <td><c:out value="${row.sample}" /></td>
31    <td><c:out value="${row.memo}" /></td>
32  </tr>
33</c:forEach>
34</table>
35
36</body>
37</html>
Note: See TracBrowser for help on using the browser.