⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 复件 (2) list.jsp

📁 电子商务网站使用MVC模式B/S结构功能不是很全适合初学者看
💻 JSP
字号:
<%@ page contentType="text/html; charset=gb2312"%>
<%@page import="java.util.Hashtable"%>
<%@page import="java.util.ArrayList" %>
<script language="javascript">
	function ok(){
		form1.action="<%=request.getContextPath()%>/shoppingAction";
		form1.submit();
	}
	function checkPageNumber(){
		//检查价格
		
		if(isNaN(parseInt(document.form1.pageNumber.value))){
			alert("页码必须是数字.");
			document.form1.pageNumber.focus();
			return false;
		}
		form1.action="<%=request.getContextPath()%>/listAction";
		form1.submit();
	}
		
	function CheckAll(form){
			for (var i=0;i<form.elements.length;i++){
				var e = form.elements[i];
//		if (e.name != 'chkall')
				e.checked = true// form.chkall.checked;
			}
		}
	function CheckOthers(form){
		for (var i=0;i<form.elements.length;i++){
			var e = form.elements[i];
			if (e.checked==true){
				e.checked = false;
				if(document.getElementById[e.value].value==""){
				
					alert("请输入用户名.");
					return false;
				}
			}
			else{
			e.checked = true;
			}
		}
	}
</script>


<% 
		if(request.getParameter("logged")!=null){
%>
			<script language="javascript">
				alert("你还未登陆");
			</script>
<%	
		}else if(request.getParameter("done")!=null){		
%>		
			<script language="javascript">
				alert("操作成功");
			</script>
<%
		}	
%>		
<style type="text/css">
<!--
A {
    COLOR: #3333CC; TEXT-DECORATION: none ;border-bottom:1px dotted
}
.mobile_top5_1{
	margin:5px 4;
	padding:0;
	width:190px;
	height:127px;
   background:url(<%=request.getContextPath()%>/image/moblie_bg1.gif);
}
.mobile_top5_1 h4{
 margin:15px 3px 2 3px;
 font-size:12px; 
 width:20px; 
 height:100px; 
 float:left; 
 text-align: center; 
 font-weight:normal;
}
.mobile_top5_1 table{
margin:5px 5px 2px 0; 
float:right;
}
.style1 {color: #663300}
.style3 {font-size: 12px}
.style4 {color: #3333CC}
-->
</style>
<center>
<table   width="700" height="333" border="1" align="center" cellpadding="0" cellspacing="1">
  <tr >
    <td valign="top" width="198" height="140">
		<table width="160" height="140" cellspacing="1">
	  		<tr><td  background="image/top01_3.gif" colspan="2">
				<span class="style1"  >搜索选项</span>
				</td>
			</tr>	
	  		<form name="form1" method="post" action="">
    		<tr><td class="style1">手机品牌 </td>
    		<td>
        		<select name="card" id="select">
				<option>ssgsgsgsg</option>
       			</select>
			  </td>
   			</tr>
          
    		<tr><td class="style1">手机型号</td>
    		<td>
    			<select name="num" id="select2">
    			</select>
   			  </td>
    		</tr>
    		<tr><td class="style1">手机类型</td>
    		<td>
    			<select name="model" id="select3">
    			</select>
   			  </td>
    		</tr>
    		<tr><td class="style1">拍照功能</td>
    		<td>
    			<select name="photo" id="select4">
    			</select>
			  </td>
    		</tr>
    		<tr><td class="style1">网络制式</td>
    		<td>
    			<select name="net" id="select5">
   			 	</select>
   			  </td>
    		</tr>
    		<tr><td class="style1">功能特点</td>
    		<td>
    			<select name="special" id="select6">
    			</select>
			  </td>
    		</tr>
        	<tr><td height="23"><input name="key" type="text" id="key" size="8"></td><td>
        		<input type="submit" name="Submit" value="查找">
				</td>
    		</tr>
        
    </form>
	  </table>	</td>
    <td valign="top" width="542" rowspan="2">
		<table>
		<form action="print.jsp" name="form1" method="post" > 
<center>
  			  <tr><td background="<%=request.getContextPath()%>/image/top01_3.gif" colspan="5">&nbsp;</td></tr>
  			  <tr>
				<td width="16" background="<%=request.getContextPath()%>/image/top01_3.gif"> </td>
  			    <td width="154"><div align="center" class="style1">图片</div></td>
  			    <td width="335"><div align="center" class="style1">商品名称和描述</div></td>
  			    <td width="55"><div align="center" class="style1">单价</div></td>
  			    <td width="50"><div align="center" class="style1">数量</div></td>
  			  </tr>
			<%	
				ArrayList list;
				Hashtable table=new Hashtable();
	
				list=(ArrayList)(session.getAttribute("list"));
    //out.print(list.size());
    //table=(Hashtable)(list.get(1));	
    
				String card="",num="",model="",photo="",net="",price="",special="",picture="",describe="",restNum="";
				int id=0;
				if(list!=null){	
					for(int i=0;i<list.size();i++){
						table=(Hashtable)list.get(i);
		//	out.print(i);	
						card=table.get("card".toUpperCase()).toString();
						num=table.get("num".toUpperCase()).toString();
						model=table.get("model".toUpperCase()).toString();
						photo=table.get("photo".toUpperCase()).toString();
						net=table.get("net".toUpperCase()).toString();
						price=table.get("price".toUpperCase()).toString();
						price=price.substring(0,price.indexOf("."));
						special=table.get("special".toUpperCase()).toString();
						picture=table.get("picture".toUpperCase()).toString();
						describe=table.get("describe".toUpperCase()).toString();
						id=Integer.parseInt(table.get("id".toUpperCase()).toString());
						restNum=table.get("restNum".toUpperCase()).toString();
						out.print("<tr><td width=5><input type=checkbox name=id  value=\""+id+"\" ></td>");
						out.print("<td class=\"style1\" align=\"center\"><img src=\""+picture+"\" width=86 height=83</td>");
						out.print("<td class=\"style1\" align=\"left\">"+card+":"+num+"<br>"+describe+"</td>");
						out.print("<td class=\"style1\" align=\"center\">"+price+"</td>");
						out.print("<td class=\"style1\" align=\"center\">"+restNum+"</td>");
		//	out.print(i);
						out.print("</tr>");
					}
				}
			%>
				<tr>
				  <td colspan="6" align="right" bgcolor="#FFCCFF" background="<%=request.getContextPath()%>/image/top01_3.gif" >
				  <div align="right">
				  <span class="style1">
						<a href="shopping_look_action.jsp">
						查看购物车</a> 
						<a href="javascript:ok()">放入购物车</a></span>
						<input type="button" name="chkother" value="反选" onclick="CheckOthers(this.form)" title="反向选择歌曲">
				  </div>
				  </td>
				</tr> 
				<tr> 
				  <td align="right" bgcolor="#CCCCCC" background="<%=request.getContextPath()%>/image/top01_3.gif" colspan="5">
				  <% int dirPage=4;
					int startPage=1;
					int pageNumber=1;
					if(session.getAttribute("pageNumber")!=null){
						pageNumber=Integer.parseInt(session.getAttribute("pageNumber").toString());
						startPage=1+pageNumber-pageNumber%dirPage;
						out.print("<b><span class=\"style1\">第"+pageNumber+"页</span></b>/");
						out.print("<span class=\"style1\">共"+session.getAttribute("pages").toString()+"页 </span>");
						if(pageNumber!=1){
							out.print("<span class=\"style1\">|<a href=\""+request.getContextPath()+"/listAction?pageNumber=1\">第1页</a>|</span>");
						}else{
							out.print("<span class=\"style1\">|第1页|</span>");
						}
						if(startPage!=1){
							int prePageNumber=startPage-4;
							out.print("<span class=\"style1\">|<a href=\""+request.getContextPath()+"/listAction?pageNumber="+prePageNumber+"\">上页</a>|--</span>");
						}else {
							out.print("<span class=\"style1\">|上页|--</span>");
						}
					}
					if(session.getAttribute("pages")!=null){
						int pages=Integer.parseInt(session.getAttribute("pages").toString());
						for(int i=startPage;i<startPage+dirPage&&i<=pages;i++){
							out.print("<span class=\"style2\">|<a href=\""+request.getContextPath()+"/listAction?pageNumber="+i+"\">"+i+"</a>|");
						}
			
						if(startPage/4<(pages-1)/4){
							int nextPageNumber=startPage+4;
							out.print("<span class=\"style1\">|<a href=\""+request.getContextPath()+"/listAction?pageNumber="+pages+"\">最后1页</a>|</span>");
						}else {
							out.print("<span class=\"style1\">--|下页|</span>");
						}
						if(pageNumber!=pages){
							out.print("<span class=\"style1\">|<a href=\""+request.getContextPath()+"/listAction?pageNumber="+pages+"\">最后1页</a>|</span>");
						}else{
							out.print("<span class=\"style1\">|最后1页|</span>");
						}
					}	
					out.print(" </span><span class=\"style1\">到第<input type=\"text\" size=4 name=\"pageNumber\">页");
					out.print("<input name=\"go\" type=\"button\" id=\"go\" value=\"显示\" onclick=\"javascript:checkPageNumber()\"></span>");
				   %>
				  </td>	
				</tr>
			</center>
			<script>
function del(){
	form1.action="<%=request.getContextPath()%>/delListAction";
	form1.submit();
}
function edit(){

	form1.action="<%=request.getContextPath()%>/editListAction";
	form1.submit();
}
function show(){
	form1.action="<%=request.getContextPath()%>/listAction";
	form1.submit();
}
			</script>
		  </form>
		</table>		
	</td>
  </tr>
  <tr>
    <td  >
		<DIV class=mobile_top5_1>
			<H4>人气排行榜</H4>
			<TABLE cellSpacing=0 cellPadding=0 width=150 border=0>
				<TBODY>
					<TR>
						<TH scope=col align=middle width=30 height=18><span class="style3">排行</span></TH>
						<TH width=85 height=18 align=middle class="style3" scope=col>机型</TH>
						<TH width=45 height=18 align=middle class="style3 style4" scope=col>人气值</TH>
					</TR>
					<%	
						list=(ArrayList)(application.getAttribute("adList"));
						if(list!=null){	
							for(int i=0;i<list.size();i++){
								table=(Hashtable)list.get(i);
								int concern=1;
								concern=Integer.parseInt(table.get("concern".toUpperCase()).toString());
								if(concern/100>15)concern=30;
								else if(concern/100>14)concern=28;
								else if(concern/100>13)concern=26;
								else if(concern/100>12)concern=24;
								else if(concern/100>11)concern=22;
								else if(concern/100>10)concern=20;
								else if(concern/100>9)concern=18;
								else if(concern/100>8)concern=16;
								else if(concern/100>7)concern=14;
								else if(concern/100>6)concern=12;
								else if(concern/100>5)concern=10;
								else if(concern/100>4)concern=8;
								else if(concern/100>3)concern=6;
								else if(concern/100>2)concern=4;
								else concern=1;
								String str=table.get("showString".toUpperCase()).toString();
								id=	Integer.parseInt(table.get("id".toUpperCase()).toString());
								if(i%2==0)out.print("<TR align=middle bgColor=#f3f3f3>");
								else out.print("<TR align=middle>");
								out.print("<TD height=18>"+(i+1)+"</TD>");
								out.print("<TD align=left height=18><a href=\""+request.getContextPath()+"/showCommodity?id="+id+"\" >"+str+"</a></TD>");
								out.print("<TD align=left height=18><IMG height=7 src=\""+request.getContextPath()+"/image/hotlevel.gif\" width="+concern+"></TD>");
								out.print("</TR>");
							}
						}
					%>
				</TBODY>
		  </TABLE>
		</DIV>	
		<DIV class=mobile_top5_1>
			<H4>人气排行榜</H4>
			<TABLE cellSpacing=0 cellPadding=0 width=140 border=0>
				<TBODY>
					<TR>
						<TH scope=col align=middle width=43 height=18><span class="style3">排行</span></TH>
						<TH width=63 height=18 align=left class="style3" scope=col>机型</TH>
						<TH width=50 height=18 align=middle class="style3 style4" scope=col>人气值</TH>
					</TR>
					<%	
						list=(ArrayList)(application.getAttribute("adList"));
						if(list!=null){	
							for(int i=0;i<list.size();i++){
								table=(Hashtable)list.get(i);
								int concern=1;
								concern=Integer.parseInt(table.get("concern".toUpperCase()).toString());
								if(concern/100>15)concern=30;
								else if(concern/100>14)concern=28;
								else if(concern/100>13)concern=26;
								else if(concern/100>12)concern=24;
								else if(concern/100>11)concern=22;
								else if(concern/100>10)concern=20;
								else if(concern/100>9)concern=18;
								else if(concern/100>8)concern=16;
								else if(concern/100>7)concern=14;
								else if(concern/100>6)concern=12;
								else if(concern/100>5)concern=10;
								else if(concern/100>4)concern=8;
								else if(concern/100>3)concern=6;
								else if(concern/100>2)concern=4;
								else concern=1;
								String str=table.get("showString".toUpperCase()).toString();
								id=	Integer.parseInt(table.get("id".toUpperCase()).toString());
								if(i%2==0)out.print("<TR align=middle bgColor=#f3f3f3>");
								else out.print("<TR align=middle>");
								out.print("<TD height=18>"+i+1+"</TD>");
								out.print("<TD align=left height=18><a href=\""+request.getContextPath()+"/showCommodity?id="+id+"\" >"+str+"</a></TD>");
								out.print("<TD align=left height=18><IMG height=7 src=\""+request.getContextPath()+"/image/hotlevel.gif\" width="+concern+"></TD>");
								out.print("</TR>");
							}
						}
					%>
				</TBODY>
		  </TABLE>
		</DIV>
	  </td>
  </tr>
</table>
</center>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -