<sql:setDataSource var="dataSrc" url="jdbc:mysql:///taglib" driver="org.gjt.mm.mysql.Driver" user="admin" password="secret"/>
<sql:query var="queryResults" dataSource="${dataSrc}">
select * from blog group by created desc limit ?
<sql:param value="${6}"/>
</sql:query>
<table border="1"> <tr> <th>ID</th> <th>Created</th> <th>Title</th> <th>Author</th> </tr>
<c:forEach var="row" items="${queryResults.rows}"> <tr> <td>
<c:out value="${row.id}"/></td> <td>
<c:out value="${row.created}"/></td> <td>
<c:out value="${row.title}"/></td> <td>
<c:out value="${row.author}"/></td> </tr>
</c:forEach>
</table>
下面是事务支持方面:
<sql:transaction> <sql:update sql="update blog set title = ? where id = ?">
<sql:param value="New Title"/>
<sql:param value="${23}"/>
</sql:update> <sql:update sql="update blog set last_modified = now() where id = ?">
<sql:param value="${23}"/>
</sql:update></sql:transaction>
<sql:query var="queryResults" dataSource="${dataSrc}">
select * from blog group by created desc limit ?
<sql:param value="${6}"/>
</sql:query>
<table border="1"> <tr> <th>ID</th> <th>Created</th> <th>Title</th> <th>Author</th> </tr>
<c:forEach var="row" items="${queryResults.rows}"> <tr> <td>
<c:out value="${row.id}"/></td> <td>
<c:out value="${row.created}"/></td> <td>
<c:out value="${row.title}"/></td> <td>
<c:out value="${row.author}"/></td> </tr>
</c:forEach>
</table>
下面是事务支持方面:
<sql:transaction> <sql:update sql="update blog set title = ? where id = ?">
<sql:param value="New Title"/>
<sql:param value="${23}"/>
</sql:update> <sql:update sql="update blog set last_modified = now() where id = ?">
<sql:param value="${23}"/>
</sql:update></sql:transaction>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货