?? index.jsp
字號:
<%@ page import="java.util.Iterator" %>
<%@ page import="cn.register.product.SqlProduct" %>
<%@ page import="cn.register.product.Product" %>
<%@ page import="cn.register.Factory" %>
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注冊登錄系統首頁</title>
<link rel="stylesheet" href="register.css" type="text/css"/>
</head>
<%
String UserId = (String)session.getAttribute("user"); //從session中獲取用戶ID
if(UserId == null || UserId == "") //判斷用戶ID是否為空,即判斷是否登錄
// response.sendRedirect("login.jsp"); //未登錄則跳轉到login.jsp登錄頁面
response.sendRedirect("login.jsp?info=0");
Product product = null;
SqlProduct sqlProduct = Factory.getInstance().initSqlProduct();//初始化SqlProduct類
Iterator iterator = sqlProduct.getProducts(); //該方法返回Iterator“反復器”數據類型
String product_name = ""; //定義產品名稱變量
float price; //定義產品價格變量
String description = ""; //定義產品描述變量
%>
<body>
<table width="80%" align="center">
<tr>
<td class="title"> 用戶注冊登錄系統==<span class="title1">產品展示</span>==</td>
<td style="width:150; height:20; vertical-align:middle; text-align:center;">
<%=UserId%> 您好! <a href="login.jsp?info=0">登錄
</a> | <a href="logout.jsp">注銷</a></td>
</tr>
</table>
<hr align="center" width="75%" color="#990000" size="1"/>
<table width="80%" align="center">
<tr><td height="5" colspan="2"></td></tr>
<%
while(iterator.hasNext()){ //循環輸出產品信息
product = (Product)iterator.next();
product_name = product.getProduct_name();
price = product.getPrice();
description = product.getDescription();
%>
<tr>
<td> 產品名稱:<%=product_name%></td><td width="40%"> 報價:
<span style="color:#FF0000; font-style:italic;"><%=price%></span></td>
</tr>
<tr>
<td colspan="2"> 描述:<%=description%></td>
</tr>
<tr><td height="5" colspan="2"><hr size="3" width="10%"/></td></tr>
<%
}
%>
</table>
<div align="center" class="tail">2006==本公司版權擁有</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -