日期:2014-05-17 浏览次数:21095 次
public List<Category> QueryCategory(String ctype)
{
List<Category> categorys = new ArrayList<Category>();
Connection conn = null;
PreparedStatement pre = null;
String sql = "SELECT * FROM category WHERE ctype = ? ";
ResultSet rs = null;
try
{
conn = JdbcUtils.getConnection();
pre = conn.prepareStatement(sql);
pre.setString(1,ctype);
rs = pre.executeQuery();
while(rs.next())
{
Category category = new Category();
category.setCtype(rs.getString("ctype"));
category.setChot(rs.getBoolean("chot"));
category.setCid(rs.getInt("cid"));
Account account = new Account();
account.setAid(rs.getInt("aid"));
category.setAccount(account);
categorys.add(category);
}
} catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}finally
{
JdbcUtils.free(rs,pre,conn);
}
return categorys.size() == 0 ? null : categorys;
}
<body>
<form action="/t31/CategorySer" method="post">
查询:<input type="text" name="ctype" /><br />
<input type="submit" value="提交" />
<input type="hidden" value="queryCategory" name="status" />
</form>
<c:if test="${requestScope.categorys!=null}">
<table>
<tr>
<td>编号</td>
<td>类别名</td>
<td>是否热点</td>
<td>所属客服</td>
</tr>
<c:forEach items="${requestScope.categorys}" var="category" varStatus="num">
<tr>
<td>${num.count}</td>
<td>${category.ctype}</td>
<td>
<c:choose>
<c:when test="${category.chot=='true'}">
<input type="checkbox" checked="checked" value="true" disabled="disabled" />
</c:when>
<c:otherwise>
<input type="checkbox" value="true" disabled="disabled" />
</c:otherwise>
</c:choose>
</td>
<td>${category.account.alogin}</td>
</tr>
</c:forEach>
</table>
</c:if>
</body>
</html>