4-7练习
<%@ page language="java" contentType="text/html; charset=UTF-8" errorPage="error.jsp" pageEncoding="UTF-8" import="com.imooc.db.*,com.imooc.bean.*,java.util.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Insert title here</title> </head> <body> <% String account = request.getParameter("account"); String password = request.getParameter("password"); Emp emp = new Emp(account,null,password,null); boolean flag = DBUtil.selectEmpByAccountAndPassword(emp); Map<String,Emp> map = DBUtil.map; if(flag == true){ %> <h3 align="center">公告列表为:</h3> <hr> <br/> <form action="select.jsp"> <table align="center" border="1" width="500px"> <tr> <td>公告编号:</td> <td><input type="text" name="account"></td> <td><input type="submit" value="select"></td> </tr> </table> </form> <br/><br/> <table align="center" border="1" width="500px"> <tr> <td>编号</td> <td>名称</td> <td>内容</td> <td>删除</td> <td>修改</td> </tr> <% for(String key : map.keySet()){ Emp e = map.get(key); %> <tr> <td><%= e.getAccount() %></td> <td><%= e.getName() %></td> <td><%= e.getContent() %></td> <td><a href="delete.jsp?account=<%= e.getAccount() %>">删除</a></td> <td><a href="update.jsp?account=<%= e.getAccount() %>&name=<%= e.getName() %>&content=<%= e.getContent() %>">修改</a></td> </tr> <% } %> </table> <% }else{ throw new Exception("账号和密码错误"); } %> </body> </html>
选择:
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" import="com.imooc.db.DBUtil, com.imooc.bean.Emp" language="java" %> <%@ page import="java.util.Map" %> <html> <head> <title>查询</title> </head> <body> <% String account = request.getParameter("account"); Map<String, Emp> map = DBUtil.map; Emp emp = map.get(account); %> <h3>公告列表:</h3> <hr/><br/> <form action="control.jsp"> <table align="center" width="500px" border="1"> <tr> <td>公告编号:</td> <td><input type="text" value="<%= account %>"></td> <td><input type="submit" value="back"></td> </tr> </table> </form> <table align="center" width="500px" border="1"> <tr> <td>编号</td> <td>名称</td> <td>内容</td> <td>删除</td> <td>修改</td> </tr> <tr> <td><%= emp.getAccount()%></td> <td><%= emp.getName()%></td> <td><%= emp.getContent()%></td> <td><a href="delete.jsp?account=<%= emp.getAccount() %>">删除</a></td> <td><a href="update.jsp?account=<%= emp.getAccount() %>&name=<%= emp.getName() %>&content=<%= emp.getContent() %>">修改</a></td> </tr> </table> </body> </html>
19
收起
正在回答 回答被采纳积分+1
从网页搭建入门Java Web2018版
- 参与学习 人
- 提交作业 1088 份
- 解答问题 10205 个
如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星