登录界面:
HTML代码如下:
<body id="p2"> <p id="p5" align="right"> <a href="homework_map.html">美食图鉴</a> <a href="href5_baidu.html">美食咨询</a> </p> <p id="p1" align="center">人间烟火</p> <table width="100%"> <tr> <td align="center"> <form action="/dcan/zcservlet"> <label> 账号:<input type="text" size="35px" id="p3" name="id"><br><br> 密码:<input type="password" size="35px" width="20" id="p3" name="password"><br><br> <input type="submit" value="登录" name="1"> <input type="submit" value="注册" name="1"> </label> </form> </td> </tr> </table> <address id="p4"> 宅急送美食广场 邮箱:88888888@qq.com<br> <a href="mailto:1434881861@qq.com cc=163.com&bcc=123456789@qq.com&subject=20%again">问题反馈</a>.<br> </address> </body>
具体效果:
登录后进入后台进行用户认证,判定是否存在或者密码是否正确:
req.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8"); resp.setContentType("text/html;charset=UTF-8"); //获得数据库的连接 DBUtil util = new DBUtil(); Connection conn = null; //数据库操作类 Statement stat = null; ResultSet rs = null; try { conn = util.getconn(); stat = conn.createStatement(); //获取按钮值 String value = req.getParameter("1"); if("登录".equals(value)) { //登录页面 String id = req.getParameter("id"); String password = req.getParameter("password"); int idd = Integer.parseInt(id); rs = stat.executeQuery("select * from d_users where id=" + idd); if(rs.next()) { String pass = rs.getString("password"); if(pass.equals(password)) { }else { resp.getWriter().write("<style type=\"text/css\">\r\n" + "a{font-size=40px;margin-left: 49%;}" + " </style>"); resp.getWriter().write("<h2 align='center'>密码错误</h2>"); resp.getWriter().write("<a href='/dcan/homework1.html' align='center' font-size=30px>返回</a>"); } }else { resp.getWriter().write("<style type=\"text/css\">\r\n" + "a{font-size=40px;margin-left: 49%;}" + " </style>"); resp.getWriter().write("<h3 align='center'>用户不存在</h3>"); resp.getWriter().write("<a href='/dcan/homework1.html' align='center' >返回</a>"); } }else { //注册页面 req.getRequestDispatcher("/zc.html").forward(req, resp); } } catch (Exception e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } finally { try { if(rs != null) rs.close(); if(stat != null) stat.close(); if(conn != null) conn.close(); } catch (SQLException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } }
主界面:
暂时只写了一个模块,后面还会有其他的模块:
<body bgcolor="#F8F8F8"> <table align="center" width="100%"> <tr id="tr1"> <th colspan="2"> <img src="images/b1.jpg"/> </th> <th colspan="2"> <form action=""> <input type="text" id="n" name="n" value=""> <input type="submit" id="s" value="搜索店铺"> </form> </th> </tr> </table> <table align="center" width="70%" id="table2"> <tr id="tr2"> <td align="center"><a href="" id="a1" target="_self">首页</a></td> <td align="center"><a href="" id="a1" target="_self">中式料理</a></td> <td align="center"><a href="" id="a1" target="_self">异国美食</a></td> <td align="center"><a href="" id="a1" target="_self">饮品甜点</a></td> <td align="center"><a href="" id="a1" target="_self">小吃夜宵</a></td> </tr> </table> <hr color="#FF6B37"> <table align="center" width="70%"> <tr> <td width="22%" id="td1"> <table background="images/b2.jpg" id="table4"> <tr> <th align="left">成都美食</th> </tr> <tr> <td> <fieldset > <table> <tr> <th colspan="3" align="left"><span id="th1">商区</span></th> <th><a href="" target="_self" id="aa">更多</a></th> </tr> <tr> <td><a href="" target="" id="aa">春熙路</a></td> <td><a href="" target="" id="aa">牛市口</a></td> <td><a href="" target="" id="aa">火车站</a></td> </tr> <tr> <td><a href="" target="" id="aa">茶店子</a></td> <td><a href="" target="" id="aa">西南交大</a></td> <td><a href="" target="" id="aa">天府广场</a></td> </tr> <tr> <td><a href="" target="" id="aa">宽窄巷子</a></td> <td><a href="" target="" id="aa">梁家巷</a></td> <td><a href="" target="" id="aa">万年场</a></td> </tr> </table> </fieldset> </td> </tr> <tr id="tr0"> <td> <fieldset > <table> <tr> <th colspan="3" align="left"><span id="th1">菜系</span></th> <th><a href="" target="_self" id="aa">更多</a></th> </tr> <tr> <td><a href="" target="" id="aa">家常菜</a></td> <td><a href="" target="" id="aa">日系料理</a></td> <td><a href="" target="" id="aa">法式料理</a></td> </tr> <tr> <td><a href="" target="" id="aa">农家菜</a></td> <td><a href="" target="" id="aa">川菜</a></td> <td><a href="" target="" id="aa">下午茶</a></td> </tr> <tr> <td><a href="" target="" id="aa">人气餐厅</a></td> <td><a href="" target="" id="aa">食品保健</a></td> <td><a href="" target="" id="aa">饮品店</a></td> </tr> </table> </fieldset> </td> </tr> <tr id="tr0"> <td> <fieldset > <table> <tr> <th colspan="3" align="left"><span id="th1">氛围</span></th> <th><a href="" target="_self" id="aa">更多</a></th> </tr> <tr> <td><a href="" target="" id="aa">浪漫约会</a></td> <td><a href="" target="" id="aa">朋友聚餐</a></td> <td><a href="" target="" id="aa">家庭聚会</a></td> </tr> <tr> <td><a href="" target="" id="aa">商务宴请</a></td> <td><a href="" target="" id="aa">休闲小憩</a></td> <td><a href="" target="" id="aa">随便吃吃</a></td> </tr> </table> </fieldset> </td> </tr> </table> </td> <td id="td1" width="100%"> <table id="table4"> <tr> <td> <table id="table3" bgcolor="white"> <tr> <th colspan="2" align="left" > <span>午餐优选</span> </th> </tr> <tr> <td> <fieldset > <table > <tr> <td rowspan="2"><img src="images/bb1.jpg"></td> <td><span>良美基</span></td> </tr> <tr> <td><span>人均20 </span><a href="/lmjservlet">去看看</a></td> </tr> </table> </fieldset> </td> <td> <fieldset > <table > <tr> <td rowspan="2"><img src="images/bb1.jpg"></td> <td><span>良美基</span></td> </tr> <tr> <td><span>人均20 </span><a href="/lmjservlet">去看看</a></td> </tr> </table> </fieldset> </td> </tr> <tr> <td> <fieldset > <table > <tr> <td rowspan="2"><img src="images/bb1.jpg"></td> <td><span>良美基</span></td> </tr> <tr> <td><span>人均20 </span><a href="/lmjservlet">去看看</a></td> </tr> </table> </fieldset> </td> <td> <fieldset > <table > <tr> <td rowspan="2"><img src="images/bb1.jpg"></td> <td><span>良美基</span></td> </tr> <tr> <td><span>人均20 </span><a href="/lmjservlet">去看看</a></td> </tr> </table> </fieldset> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body>