Web课程设计Word文档格式.docx
- 文档编号:18529844
- 上传时间:2022-12-19
- 格式:DOCX
- 页数:52
- 大小:657.53KB
Web课程设计Word文档格式.docx
《Web课程设计Word文档格式.docx》由会员分享,可在线阅读,更多相关《Web课程设计Word文档格式.docx(52页珍藏版)》请在冰豆网上搜索。
表:
admin
message
user
系统实现代码
Login.java
packagemybean.data;
publicclassLogin
{Stringlogname,
password,
backNews="
"
;
booleansuccess=false;
publicvoidsetLogname(Stringname)
{logname=name;
}
publicStringgetLogname()
{returnlogname;
publicvoidsetPassword(Stringpw)
{password=pw;
publicStringgetPassword()
{returnpassword;
publicStringgetBackNews()
{returnbackNews;
publicvoidsetBackNews(Strings)
{backNews=s;
}
publicvoidsetSuccess(booleanb)
{success=b;
publicbooleangetSuccess()
{returnsuccess;
}
Message.java
publicclassMessage{
Stringlogname="
message="
time="
title="
backNews;
publicvoidsetLogname(Stringname)
{returnlogname;
publicvoidsetTitle(Stringt)
{title=t;
publicStringgetTitle()
{returntitle;
publicvoidsetTime(Stringt)
{time=t;
publicStringgetTime()
{returntime;
publicStringgetMessage()
{returnmessage;
publicvoidsetMessage(Stringm)
{message=m;
{returnbackNews;
publicvoidsetBackNews(Strings)
Register.java
publicclassRegister
{Stringlogname="
password="
qq="
email="
phone="
StringbackNews;
publicvoidsetLogname(Stringname)
{logname=name;
publicStringgetLogname()
{returnlogname;
publicvoidsetQq(Stringq)
{qq=q;
publicStringgetQq()
{returnqq;
publicvoidsetPassword(Stringpw)
{password=pw;
publicStringgetPassword()
{returnpassword;
publicvoidsetEmail(Stringem)
{email=em;
publicStringgetEmail()
{returnemail;
publicvoidsetPhone(Stringph)
{phone=ph;
publicStringgetPhone()
{returnphone;
publicStringgetBackNews()
{returnbackNews;
publicvoidsetBackNews(Strings)
{backNews=s;
ConditionQuery.java
importjava.sql.*;
publicclassConditionQuery
{Stringlogname;
StringBufferqueryResultBylogname;
publicConditionQuery()
{queryResultBylogname=newStringBuffer();
try{Class.forName("
com.microsoft.sqlserver.jdbc.SQLServerDriver"
);
catch(Exceptione){}
publicvoidsetlogname(Strings)
{logname=s.trim();
queryResultBylogname=newStringBuffer();
publicStringgetlogname()
{returnlogname;
publicStringBuffergetQueryResultBylogname()
{Stringcondition="
SELECT*FROMmessageWherelogname='
+logname+"
'
queryResultBylogname=f(condition);
returnqueryResultBylogname;
privateStringBufferf(Stringcondition)
{StringBufferstr=newStringBuffer();
Connectioncon;
Statementsql;
ResultSetrs;
try{Stringuri="
jdbc:
sqlserver:
//127.0.0.1:
1433;
DatabaseName=factory"
con=DriverManager.getConnection("
odbc:
4073"
"
sql=con.createStatement();
rs=sql.executeQuery(condition);
str.append("
<
tableborder=1>
thwidth=100>
+"
logname"
title"
message"
time"
while(rs.next())
{str.append("
tr>
td>
+rs.getString
(1)+"
/td>
+rs.getString
(2)+"
+rs.getString(3)+"
+rs.getString(4)+"
/tr>
con.close();
catch(SQLExceptione)
{System.out.println(e);
returnstr;
}
HandleAdmin.java
packagemyservlet.control;
importmybean.data.*;
importjava.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
publicclassHandleAdminextendsHttpServlet
{publicvoidinit(ServletConfigconfig)throwsServletException
{super.init(config);
try{Class.forName("
sun.jdbc.odbc.JdbcOdbcDriver"
catch(Exceptione){}
publicStringhandleString(Strings)
{try{bytebb[]=s.getBytes("
iso-8859-1"
s=newString(bb);
catch(Exceptionee){}
returns;
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException
{Connectioncon;
PreparedStatementsql;
LoginloginBean=null;
StringbackNews="
HttpSessionsession=request.getSession(true);
try{loginBean=(Login)session.getAttribute("
login"
if(loginBean==null)
{loginBean=newLogin();
session.setAttribute("
loginBean);
catch(Exceptionee)
Stringlogname=request.getParameter("
).trim(),
password=request.getParameter("
password"
).trim();
booleanok=loginBean.getSuccess();
logname=handleString(logname);
password=handleString(password);
if(ok==true&
&
logname.equals(loginBean.getLogname()))
{backNews=logname+"
你已经登录了"
loginBean.setBackNews(backNews);
else
{
booleanboo=(logname.length()>
0)&
(password.length()>
0);
try{con=DriverManager.getConnection("
Stringcondition="
select*fromadminwherelogname=?
andpassword=?
sql=con.prepareStatement(condition);
if(boo)
{sql.setString(1,logname);
sql.setString(2,password);
ResultSetrs=sql.executeQuery();
booleanm=rs.next();
if(m==true)
{backNews="
管理员登录成功"
loginBean.setSuccess(true);
loginBean.setLogname(logname);
您登陆的管理员不存在,或密码不对"
loginBean.setSuccess(false);
loginBean.setPassword(password);
您输入的管理员不存在,或密码不对"
catch(SQLExceptionexp)
+exp;
RequestDispatcherdispatcher=request.getRequestDispatcher("
showAdminMess.jsp"
dispatcher.forward(request,response);
publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)
{doPost(request,response);
HandleLogin.java
publicclassHandleLoginextendsHttpServlet
select*fromuserwherelogname=?
会员登录成功"
您输入的会员不存在,或密码不对"
showLoginMess.jsp"
HandleMessage.java
importjava.util.Date;
importjava.text.SimpleDateFormat;
publicclassHandleMessageextendsHttpServlet
{super.init(config);
publicStringhandleString(Strings)
{try{bytebb[]=s.getBytes("
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Web 课程设计