📄 carinfo.jsp
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312" import="java.sql.*,java.util.Date"%>
<%--@ page import="java.util.*"--%>
<jsp:useBean id="info" class="Bean.DbConn" scope="request"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function check()
{
if(document.myform.comment.value=="")
{
alert("内容不能为空!");
document.myform.comment.focus();
return false;
}
}
</script>
</head>
<body>
<%@ include file="index_top.jsp"%>
<%
ResultSet rs=null;
int car_id=Integer.parseInt(request.getParameter("car_id"));
info.open();
String sql="update car set browse_num=browse_num+1 where car_id="+car_id;
String strSql="select bname,type,price,prodtime,browse_num,cover,manufacturer,introduction from car,category where car.brand_id=category.brand_id and car_id="+car_id;
int i=info.executeUpdate(sql);
rs=info.executeQuery(strSql);
if(rs.next())
{
String bname=rs.getString("bname");
String type=rs.getString("type");
String price=rs.getString("price");
String p=rs.getString("prodtime");
String prodtime=p.substring(0,10);
String browse_num=rs.getString("browse_num");
String cover="<img src='C:\\Program Files\\Tomcat 5.5\\webapps\\ROOT\\car\\images\\"+rs.getString("cover")+"'>";
String manufacturer=rs.getString("manufacturer");
String introduction=rs.getString("introduction");
out.print("<center>");
out.println("<table border='1' bordercolor='#cccccc'>");
out.print("<tr><td rowspan='4' width='130' height='100'>"+cover+"</td>");
out.print("<td>"+bname+type+"</td></tr>");
out.print("<tr><td>生产厂家:"+manufacturer+"</td></tr>");
out.print("<tr><td>上市时间:"+prodtime+" 浏览次数:"+browse_num+"</td></tr>");
out.print("<tr><td>价格:"+price+"元</td></tr>");
out.print("<tr><td colspan='2'>"+introduction+"</td></tr>");
out.print("</table>");
out.print("</center>");
}
//info.close();
%>
<br>
<font color="#FF0000">温馨提示:若是VIP用户,可以发表自己的评论 </font><a href="index.jsp">登录</a> <a href="register.jsp">我要注册</a><p>
<%
String str1="select top 10 * from comment where car_id="+car_id+"order by comment_time desc";
rs=info.executeQuery(str1);
out.print("<table border='0'>");
while(rs.next())
{
String n=rs.getString("user_name");
String content=rs.getString(4);
String tm=rs.getString(5);
out.print("<tr><td><div color='#cccccc'><b>作者:"+n+"</b> <b>评论时间:"+tm+"</b></div></td></tr>");
out.print("<tr><td>"+content+"</td></tr>");
}
out.print("</table>");
%>
<!--hr size="12" width="100" align="center"-->
<p>
<%
if(request.getParameter("submit")!=null)
{
if((String)session.getAttribute("user")==null)
{
response.sendRedirect("prompt.html");
}
else
{
response.sendRedirect("sendComment.jsp?car_id="+car_id+"&comment="+request.getParameter("comment"));
}
}
%>
<form action="" method="post" onSubmit="return check()" name="myform">
<textarea name="comment" rows="6" cols="30"></textarea><br>
(评论字数200字以内)
<input type="submit" name="submit" value="发表评论"><br>
</form>
<p>
<table align="center">
<tr>
<td colspan="3"><%@ include file="index_bottom.jsp"%></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -