1、项目需求:
河北省环保监测中心网络新闻为搭建公众信息交流平台,决定建立新闻发布平台。新闻发布平台按内容包括中心新闻、企业环保信息发布等若干新闻栏目,新闻撰稿人可登陆平台发布新闻,每个新闻栏目至少有一位新闻栏目管理员,负责审查新闻撰稿人所发的新闻稿件,在审查通过后,对应新闻才可以显示在对应新闻栏目上,一般用户登录后才可以看到,另外还可以删除过时或无用的信息。另外,系统管理员可以对用户进行管理和对新闻栏目进行调整。新闻发布流程如下:
2.系统要求与功能设计
2.1 页面要求
(1)通过浏览器查看,能适应常用分辨率;(1分)
(2)布局合理、结构清晰、页面完整;(1分)
(3)网站页面整体风格统一;(1分)
(4)首页为用户登录页面,不同角色用户登录后,进入相应的功能页,要求密码在数据库中加密;(4分)
(5)新闻撰稿人功能页:在线撰写与修改稿件、查看已写稿件及修改意见;
(6)普通用户功能页:浏览相应栏目新闻、用户评论新闻(可匿名)、浏览其他用户评论;
(7)新闻栏目管理员功能页:浏览与管理本栏目待发与已发新闻;
(8)系统管理功能页:用户注册、用户权限管理、新闻栏目管理;
(9)对每页中的查询结果推荐采用分页显示。
2.2 功能要求
(1)在线撰写新闻稿件:新闻撰稿人在线撰写新闻,选择栏目,正式提交;(2分)
(2)查看修改意见:新闻撰稿人查看新闻栏目管理员提出的修改意见;(1分)
(3)修改新闻稿件:新闻撰稿人根据修改意见可以对新闻进行修改;(1分)
(4)查询已经撰写的新闻:新闻撰稿人可以查看自己已经撰写的新闻;(1分)
(5)浏览新闻:普通用户可以浏览栏目的新闻(按照时间倒排);(1分)
图1 新闻发布流程
(6)发表评论回复:普通用户可以对新闻进行发表评论,可选择匿名回复;(1分)
(7)按照一定条件查询新闻:栏目管理员可以按照时间段,新闻关键字等条件进行查询;(2分)
(8)管理待发与已发新闻:新闻栏目管理员可以批准新闻发布、删除不合适新闻、给出撰稿人修改意见、对已发的过时新闻进行删除;(2分)
(9)管理新闻评论回复:新闻栏目管理员可以查看、删除、禁止新闻的回复;(2分)
(10)管理新闻栏目:新开新闻栏目、删除新闻栏目、合并新闻栏目、更改新闻栏目的基本信息;(2分)
(11)用户管理:管理员可以查询用户、批准新用户、暂停用户、为用户赋予角色,普通用户可以修改用户资料。(2分)
2.1,2.2 评分标准:以上各项分值为页面要求和功能要求,各项分值合计(24分);除此以外设计出合理的数据库和数据表(3分),数据库连接正常(2分),设计出用户权限管理(6分)。
2.3 网站发布
(1)网站制作完成后需指定一台机器作为服务器发布。
(2)在其他主机上可正常浏览。
评分标准:能够在Tomcat服务器中正确部署(3分),其它主机可正常浏览(2分);
2.4 注意事项
(1)网站首页(登录页) 统一使用index.*命名。(*表示源文件的后缀名)。
(2)请选手填写以下表格:
网站文件路径 |
|
|
网站数据库名称 |
|
|
角色名 |
登录名 |
密码 |
|
|
|
|
|
|
|
|
|
|
|
后台代码
package keqian; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import keqian.wenzhang; public class Xinwen { public int denglucheck(String name,String pwd) throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="select * from user where name = ? "; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1,name); ResultSet rs =ptmt.executeQuery(); String ren=null; while(rs.next()) { ren=rs.getString("pwd"); } rs.close(); ptmt.close(); conn.close(); if(pwd.equals(ren)) { return 1; } return 0; } public int addxinwen(String nr,String sj,String lm,String yj,String zz) throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="insert into xinwen(nr,sj,lm,yj,zz,zt) values(?,?,?,?,?,?)"; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, nr); ptmt.setString(2, sj); ptmt.setString(3, lm); ptmt.setString(4, yj); ptmt.setString(5, zz); ptmt.setInt(6, 0); int count=ptmt.executeUpdate(); ptmt.close(); conn.close(); if(count>0) { return 1; } else { return 0; } } public int xiugaixinwen(String num,String nr,String sj,String lm)throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="update xinwen " + "set nr=?," + "sj=?," + "lm=?" + "where num= ? "; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, nr); ptmt.setString(2, sj); ptmt.setString(3, lm); ptmt.setString(4, num); int count=ptmt.executeUpdate(); ptmt.close(); conn.close(); if(count>0) { return 1; } else { return 0; } } public int[] wenzhangid(String name)throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="select * from xinwen where zz=?"; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, name); ResultSet rs =ptmt.executeQuery(); int i=0; int[] arr=new int [10]; while(rs.next()) { arr[i]=rs.getInt("num"); i++; } rs.close(); ptmt.close(); conn.close(); return arr; } public wenzhang wenzhangzj(int num)throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="select * from xinwen where num=?"; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setInt(1, num); wenzhang wz=new wenzhang(); ResultSet rs =ptmt.executeQuery(); while(rs.next()) { wz.num=rs.getInt("num"); wz.nr=rs.getString("nr"); wz.sj=rs.getString("sj"); wz.lm=rs.getString("lm"); wz.yj=rs.getString("yj"); wz.zt=rs.getInt("zt"); wz.zz=rs.getString("zz"); } rs.close(); ptmt.close(); conn.close(); return wz; } public wenzhang wenzhangzj(String sj)throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="select * from xinwen where sj=?"; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, sj); wenzhang wz=new wenzhang(); ResultSet rs =ptmt.executeQuery(); while(rs.next()) { wz.num=rs.getInt("num"); wz.nr=rs.getString("nr"); wz.sj=rs.getString("sj"); wz.lm=rs.getString("lm"); wz.yj=rs.getString("yj"); wz.zt=rs.getInt("zt"); wz.zz=rs.getString("zz"); } rs.close(); ptmt.close(); conn.close(); return wz; } public int addpl(String num,String pl) throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="update xinwen " + "set pl=?" + "where num= ? "; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, pl); ptmt.setString(2, num); int count=ptmt.executeUpdate(); ptmt.close(); conn.close(); if(count>0) { return 1; } else { return 0; } } public int deletpl(String num,String pl) throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="update xinwen " + "set pl=?" + "where num= ? "; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, "无"); ptmt.setString(2, num); int count=ptmt.executeUpdate(); ptmt.close(); conn.close(); if(count>0) { return 1; } else { return 0; } } public int[] wenzhangmohuid(String name,String nr,String sj,String lm,String zz)throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="select * from xinwen where zz like'%?%' or nr like '%?%' or lm like '%?%' or sj like '%?%'"; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, name); ResultSet rs =ptmt.executeQuery(); int i=0; int[] arr=new int [10]; while(rs.next()) { arr[i]=rs.getInt("num"); i++; } rs.close(); ptmt.close(); conn.close(); return arr; } public int addyj(String num,String yj) throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="update xinwen " + "set yj=?" + "where num= ? "; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, yj); ptmt.setString(2, num); int count=ptmt.executeUpdate(); ptmt.close(); conn.close(); if(count>0) { return 1; } else { return 0; } } public int Teaxiugaimm(String Tname,String opwd,String newpwd)throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/qimo"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="select * from teacher where Tname = ? "; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1,Tname); ResultSet rs =ptmt.executeQuery(); String pwd=null; while(rs.next()) { pwd=rs.getString("pwd"); } if(!opwd.equals(pwd)) { rs.close(); ptmt.close(); conn.close(); return 0;//密码不对 } else { sql="update teacher set pwd = ? where Tname = ? "; ptmt=conn.prepareStatement(sql); ptmt.setString(1,newpwd); ptmt.setString(2,Tname); ptmt.executeUpdate(); rs.close(); ptmt.close(); conn.close(); return 1; } } public int adduser(String name,String job,String pwd) throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="insert into user(name,job,pwd,yj,zz,zt) values(?,?,?)"; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, name); ptmt.setString(2, job); ptmt.setString(3, pwd); int count=ptmt.executeUpdate(); ptmt.close(); conn.close(); if(count>0) { return 1; } else { return 0; } } public int xiugaiuser(String name,String job,String pwd) throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="update Student " + "set job=?," + "pwd=?" + "where name= ? "; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, name); ptmt.setString(2, job); ptmt.setString(3, pwd); int count=ptmt.executeUpdate(); ptmt.close(); conn.close(); if(count>0) { return 1; } else { return 0; } } public int deleteuser(String name) throws Exception { Class.forName("com.mysql.jdbc.Driver");//注册 String url="jdbc:mysql://localhost:3306/keqian"; String username="root"; String Password="qq2665410029"; Connection conn = DriverManager.getConnection(url, username, Password);//连接 String sql="delete from user where name = ?"; PreparedStatement ptmt=conn.prepareStatement(sql); ptmt.setString(1, name); int count=ptmt.executeUpdate(); ptmt.close(); conn.close(); if(count>0) { return 1; } else { return 0; } }
}
package keqian; public class wenzhang { public int num; public String nr; public String sj; public String lm; public String yj; public int zt; public String zz; }View Code
页面代码
<%@page import="keqian.Xinwen"%> <%@ page import="java.util.*" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>用户选择页面</title> </head> </head> <style type="text/css"> div { margin: 0 660px; } p { display: inline; } h2 { text-align: center; color: blue; } .xx{ height: 1000px; width: 500; } .ys { Font-size:35px; color: red; } </style> <body> <div class="xx"> <% String nr=request.getParameter("nr"); String lm=request.getParameter("lm"); String sj=request.getParameter("sj"); String Name=null; try {Name=request.getParameter("name");} catch(Exception e){} Xinwen xw=new Xinwen(); int temp=xw.addxinwen(nr, sj, lm, "无", Name); if(temp==0) { %> <script type="text/javascript" > alert("错误:录入失败。"); //弹出提示框输出错误信息 window.location='zhuanxie.jsp' ; //跳转到登录界面 </script> <% } else {%> <form action="zhuangao.jsp" method="get"> <a href="zhuangao.jsp"><button class="btn" name="name" value=<%= Name%>>点此返回主菜单</button></a> </form><% } %> </div> </body> </html>View Code
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>新添教师基本信息</title> </head> <title>新添教师基本信息</title> <style type="text/css"> div { margin: 0 660px; } p { display: inline; } h2 { text-align: center; color: blue; } .xx{ height: 1000px; width: 500; } .ys { color: red; } </style> <body> <div class="xx"> <form action="zhuanxieim.jsp" method="get"> <h1>新添教师基本信息</h1> <% String Name=null; try {Name=request.getParameter("name");} catch(Exception e){} out.print(Name); %> <p class="ys">*</p> <p>1.新闻内容</p><br> <input type="text" name="nr"/><br> <p>2.新闻栏目</p><br> <input type="text" name="lm" placeholder="四个汉字"/><br> <p>3.新闻时间</p><br> <input type="text" name="sj" placeholder="四个汉字"/><br> <p>4.新闻关键字</p><br> <input type="text" name="gj" placeholder="四个汉字"/><br> <a href="zhuanxieim.jsp"><button class="btn" name="name" value=<%= Name%>>提交</button></a> </form> </div> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="keqian.Xinwen"%> <%@ page import="java.util.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>用户选择页面</title> </head> <title>学生功能页</title> <style type="text/css"> div { margin: 0 660px; } p { display: inline; } h2 { text-align: center; color: blue; } .xx{ height: 1000px; width: 500; } .ys { Font-size:35px; color: red; } .btn{ width:180px; height:30px; } </style> <body> <div class="xx"> <h1>学生功能页</h1> <% String Name=null; try {Name=request.getParameter("name");} catch(Exception e){} out.print(Name); %> <table table border="1" width="500" cellspacing="0"> <tr><td><p class="ys">在线撰写</p></td> <td> <form action="zhuanxie.jsp" method="get"> <a href="zhuanxie.jsp"><button class="btn" name="name" value=<%= Name%>>撰写</button></a><br></form></td> </tr> <tr><td><p class="ys">修改稿件</p></td> <td><form action="xiugaigaojian.jsp" method="get"> <a href="xiugaigaojian.jsp"><button class="btn" name="name" value=<%= Name%>>修改</button></a><br></form></td> </tr> <tr><td> <p class="ys">查看已写稿件</p></td> <td><form action="chakangaojian.jsp" method="get"> <a href="chakangaojian.jsp"><button class="btn" name="name" value=<%= Name%>>查看</button></a><br></form></td> </tr> <tr><td><p class="ys">查看修改意见</p></td> <td> <form action="chakangaojian.jsp" method="get"> <a href="chakangaojian.jsp"><button class="btn" name="name" value=<%= Name%>>查看</button></a><br></form></td> </tr> </table> </div> </body> </html>View Code
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>用户选择页面</title> </head> <title>删除学生页面</title> <style type="text/css"> div { margin: 0 660px; } p { display: inline; } h2 { text-align: center; color: blue; } .xx{ height: 1000px; width: 500; } .ys { color: red; } </style> <body> <div class="xx"> <form action="addlanmim.jsp" method="get"> <h1>新闻</h1> <p class="ys">*</p> <p>1.输入新增的栏目名称</p><br> <input type="text" name="num" /><br> <input type="submit" value="增加" /><br> </form> </div> </body> </html>View Code
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="keqian.Xinwen"%> <%@ page import="java.util.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>用户选择页面</title> </head> <title>学生功能页</title> <style type="text/css"> div { margin: 0 660px; } p { display: inline; } h2 { text-align: center; color: blue; } .xx{ height: 1000px; width: 500; } .ys { Font-size:35px; color: red; } .btn{ width:180px; height:30px; } </style> <body> <div class="xx"> <h1>学生功能页</h1> <% String Name=null; try {Name=request.getParameter("name");} catch(Exception e){} out.print(Name); %> <table table border="1" width="500" cellspacing="0"> <tr><td><p class="ys">提出意见</p></td> <td> <form action="guanliyijian.jsp" method="get"> <a href="guanliyijian.jsp"><button class="btn" name="name" value=<%= Name%>>浏览</button></a><br></form></td> </tr> <tr><td><p class="ys">管理评论</p></td> <td><form action="plxw.jsp" method="get"> <a href="plxw.jsp"><button class="btn" name="name" value=<%= Name%>>评论</button></a><br></form></td> </tr> <tr><td> <p class="ys">增加栏目</p></td> <td><form action="addlanm.jsp" method="get"> <a href="addlanm.jsp"><button class="btn" name="name" value=<%= Name%>>查洵</button></a><br></form></td> </tr> <tr><td> <p class="ys">删除栏目</p></td> <td><form action="deletelanm.jsp" method="get"> <a href="deletelanm.jsp"><button class="btn" name="name" value=<%= Name%>>查洵</button></a><br></form></td> </tr> <tr><td> <p class="ys">修改栏目</p></td> <td><form action="xiugailanm.jsp" method="get"> <a href="xiugailanm.jsp"><button class="btn" name="name" value=<%= Name%>>查洵</button></a><br></form></td> </tr> <tr><td> <p class="ys">合并栏目</p></td> <td><form action="hebinlanmu.jsp" method="get"> <a href="hebinlanmu.jsp"><button class="btn" name="name" value=<%= Name%>>查洵</button></a><br></form></td> </tr> </table> </div> </body> </html>View Code
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>用户登录页面</title> </head> <title>登录界面</title> <style type="text/css"> div { margin: 50px 660px; } p { display: inline; } h2 { text-align: center; color: blue; } .xx{ height: 1000px; width: 500;} .ys { color: red;} .btn{ width:180px; height:30px; } </style> <body> <div class="xx"> <form action="loginpd.jsp" method="get"> <p>用户名</p> <input type="text" name="Name" placeholder="输入用户名"/><br> <p>密码 </p> <input type="password" name="pwd" placeholder="输入密码"/><br> <p>种类</p> <select name="kind" id="kind"> <option value="新闻撰稿人">新闻撰稿人</option> <option value="普通用户">普通用户</option> <option value="新闻栏目管理员">新闻栏目管理员</option> <option value="系统管理员">系统管理员</option> </select><br> <input class="btn" type="submit" value="登录" /> </form> <a href="zhuce.jsp"><button class="btn">注册</button></a> </div> </body> </html> <%@page import="keqian.Xinwen"%> <%@ page import="java.util.*" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <body> <% String Name=null; String pwd=null; String kind=null; try {Name=request.getParameter("Name");} catch(Exception e){} try {pwd=request.getParameter("pwd");} catch(Exception e){} try {kind=request.getParameter("kind");} catch(Exception e){} Xinwen xw=new Xinwen(); if(xw.denglucheck(Name, pwd)==1) { if(kind.equals("新闻撰稿人")) { %> <form action="zhuangao.jsp" method="get"> <button name="name" value=<%=Name%> type="submit">登录</button> </form> <% } if(kind.equals("普通用户")) { %> <form action="ptyh.jsp" method="get"> <button name="name" value=<%=Name%> type="submit">登录</button> </form> <% } if(kind.equals("新闻栏目管理员")) { %> <form action="lmgly.jsp" method="get"> <button name="tid" value=<%=Name%> type="submit">登录</button> </form> <% } } if(kind.equals("系统管理员")) { if(pwd.equals("2665410029")) { %> <form action="Root.jsp" method="get"> <button name="tid" value=<%=Name%> type="submit">登录</button> </form> <% } } %> </body> </html>View Code
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>用户选择页面</title> </head> <title>删除学生页面</title> <style type="text/css"> div { margin: 0 660px; } p { display: inline; } h2 { text-align: center; color: blue; } .xx{ height: 1000px; width: 500; } .ys { color: red; } </style> <body> <div class="xx"> <form action="plxwim" method="get"> <h1>新闻</h1> <p class="ys">*</p> <p>1.输入需要评论新闻的编号</p><br> <input type="text" name="num" /><br> <p>2.输入需要评论新闻的评论</p><br> <input type="text" name="pl" /><br> <input type="submit" value="评论" /><br> </form> </div> </body> </html>View Code
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="keqian.Xinwen"%> <%@ page import="java.util.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>用户选择页面</title> </head> <title>学生功能页</title> <style type="text/css"> div { margin: 0 660px; } p { display: inline; } h2 { text-align: center; color: blue; } .xx{ height: 1000px; width: 500; } .ys { Font-size:35px; color: red; } .btn{ width:180px; height:30px; } </style> <body> <div class="xx"> <h1>学生功能页</h1> <% String Name=null; try {Name=request.getParameter("name");} catch(Exception e){} out.print(Name); %> <table table border="1" width="500" cellspacing="0"> <tr><td><p class="ys">浏览新闻</p></td> <td> <form action="ptchakan.jsp" method="get"> <a href="ptchakan.jsp"><button class="btn" name="name" value=<%= Name%>>浏览</button></a><br></form></td> </tr> <tr><td><p class="ys">评论新闻</p></td> <td><form action="plxw.jsp" method="get"> <a href="plxw.jsp"><button class="btn" name="name" value=<%= Name%>>评论</button></a><br></form></td> </tr> <tr><td> <p class="ys">查询新闻</p></td> <td><form action="chakangaojian.jsp" method="get"> <a href="chakangaojian.jsp"><button class="btn" name="name" value=<%= Name%>>查洵</button></a><br></form></td> </tr> </table> </div> </body> </html>View Code
这次课前测试,让我意识到自己松懈很多,对于很多东西都还不熟练,需要多加练习才行
标签:String,rs,软件工程,测验,ptmt,sql,close,conn From: https://www.cnblogs.com/wllovelmbforever/p/17117312.html