文章类别查询

// 查询新闻类别
	private void queryType(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		Integer net_id = (Integer) request.getSession().getAttribute("maxId");
		TypeDao typeDao = new TypeDao();
		request.setAttribute("typlist", typeDao.queryTypeList(net_id));
		request.getRequestDispatcher("net_queryType.jsp").forward(request,
				response);

	}


public List<Type> queryTypeList(Integer net_id) {
		List<Type> list = new ArrayList<Type>();
		sql = "select * from tb_type where net_id = " + net_id + "";
		ResultSet rs = connection.executeQuery(sql);
		try {
			while (rs.next()) {
				Type type = new Type();
				type.setId(rs.getInt(1));
				type.setType_name(rs.getString(2));
				type.setNet_id(rs.getInt(3));
				type.setSign(rs.getInt(4));
				list.add(type);
			}
		} catch (SQLException e) {
			// TODO 自动生成 catch 块
			list = null;
			e.printStackTrace();
		}
		return list;
	}


页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css/style.css" type="text/css" rel="stylesheet">
<title>qinya 学习</title>
</head>
<script language="javascript">
function Myopen(divID,id,name){ //根据传递的参数确定显示的层
	divID.style.display='block';
	divID.style.left=(document.body.clientWidth-240)/2;
	divID.style.top=(document.body.clientHeight-139)/2;	
	form1.ids.value=id;
	form1.type_name.value=name;	
}
</script>

<body onLoad="clockon(bgclock);">
<jsp:include page="common.jsp" flush="true"></jsp:include>
<jsp:include page="top.jsp" flush="true"></jsp:include>
<jsp:include page="net_Type.jsp" flush="true"></jsp:include>
<table border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="195" align="center" valign="top">
	<jsp:include page="left.jsp" flush="true"></jsp:include>	</td>
    <td align="center" valign="top">

	<table width="632" height="48" border="0" align="center" cellpadding="0" cellspacing="0" background="images/3.jpg">
      <tr>
        <td width="64">&nbsp;</td>
        <td width="568">查询网站信息类别</td>
      </tr>
    </table>
	<table width="435" height="23" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><a href="net_addType.jsp">添加类别</a></td>
        </tr>
    </table>
	<table width="435" height="30" border="1" cellpadding="0" cellspacing="0">
      <tr align="center">
        <td height="20">编号</td>
        <td>名称</td>
        <td>操作</td>
      </tr>
	  <c:forEach items="${requestScope.typlist}" var="type">	  
      <tr align="center">	  
        <td height="20">${type.id}</td>
        <td>${type.type_name}</td>
        <td>
        
        <c:if test="${type.type_name=='公告信息'||type.type_name=='焦点导读'}">
         无操作
         </c:if>
        
        
        <c:if test="${type.type_name!='焦点导读'&&type.type_name!='公告信息'}">
        <a  href="#" onClick="Myopen(type1,'${type.id}','${type.type_name}')">修改</a>&nbsp;&nbsp;&nbsp;<a href="netInformation?method=deleteType&type_id=${type.id}">删除</a>
        </c:if>
   
        </td>
      </tr>
      </c:forEach>
    </table>
	
	<div id="type1" style="position:width:240px; height:139px;display:none;">
	<br>
	<form name="form1" method="post" action="netInformation?method=updateType">
	<table width="305" border="1" cellspacing="0" cellpadding="0">
       <tr>
        <td height="30">新类别名称:</td>
        <td><input type="text" name="type_name"><input name="ids"  type="hidden" value=""></td>
      </tr>
      <tr>
        <td height="30">&nbsp;</td>
        <td><input type="submit" name="Submit" value=" 修改 "></td>
      </tr>
    </table>
	  </form>
	</div>	</td>
  </tr>
</table>
<jsp:include page="down.jsp" flush="true"></jsp:include>
</body>
</html>

你可能感兴趣的:(java,sql,.net,jsp,sun)