📄 index.jsp
字号:
<%@ page import=”cn.register.product.SqlProduct” %>
<%@ page import=”cn.register.product.Product” %>
<%@ page import=”cn.register.Factory” %>
<%@ page import=”cn.register.Iterator” %>
<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登录页面
Product product = null;
SqlProduct sqlProduct = Factory.getInstance().getSqlProduct();//初始化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">登录</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 + -