JavaWeb-简易留言板制作【MVC】

Java+Servlet+JSP

采用MVC模式(Model+View+Controller)

功能:

项目的主要模块:注册模块,登陆模块,留言列表模块,留言模块,留言详情模块。

注册模块:实现用户注册,将新注册用户数据(用户名和密码)写入数据库,并能识别该用户是否已注册,以及判断注册时密码和确认密码是否一致。

登陆模块:实现用户登陆,能够判断该用户是否已注册,用户名密码是否为空以及密码填写是否正确。

留言列表模块:展示是数据库中留言信息(包括留言数,留言标题,留言内容,留言时间以及用户ID),点击留言标题可以跳转到详细的留言页面。

留言模块:留言模块包含留言标题和留言内容,点击提交之后会将数据存在数据库中,并展示于留言列表页面。

留言详情模块:展示某项留言的详细信息,以及展示该留言下的评论。以及评论该留言。

整体框架

View:\登陆界面\注册界面\留言列表界面\留言细节界面(评论)\留言界面

1.login.jsp文件

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新浪微博</title>

<style type="text/css">
	body {
		background-color: white;
		background-size: 100% 100%;
		background-repeat:no-repeat; 
		background-attachment:fixed
		
		}
	html {
		height:100%;
		weight:100%;
	}
	label{
	color:white;
	font-weight:bolder;
	}
	.center-in-center{   
		position: absolute;   
		top: 50%;   
		left: 50%;   
		-webkit-transform: translate(-50%, -50%);   
		-moz-transform: translate(-50%, -50%);   
		-ms-transform: translate(-50%, -50%);   
		-o-transform: translate(-50%, -50%);   
		transform: translate(-50%, -50%);   
	}
	.col{
		color:white;
		font-weight:bolder;
	}
</style>
</head>

<body background="pictures/言叶之庭8.png">

<div align="center" class="center-in-center">
		<h1 class ="col">&nbsp;&nbsp;&nbsp;登陆入口</h1>
	<form action="LoginServlet" method = "post">
		<input type="hidden" name="action" value="login">
		
		<label>用户名:</label>
		<input type="text" name="username" style=width:150px;height:20px; ><br>
		
		<label>密码:</label>&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="password" name="password" style=width:150px;height:20px; ><br>
		
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="submit" name="login" value="登陆" style=width:150px;height:20px;><br>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="reset" name="reset" value="重置" style=width:150px;height:20px;><br>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<button type="submit" formaction="register.jsp" style=width:150px;height:20px;>注册</button>
	</form>
	<p class="col">${message}</p>

</div>
</body>
</html>

2.register.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>新浪微博</title>
<style type="text/css">
	body {
		background-color: white;
		background-size: 100% 100%;
		background-repeat:no-repeat; 
		background-attachment:fixed
		}
	html {
		height:100%;
		weight:100%;
	}
	label{
	color:white;
	font-weight:bolder;
	}
	h1{
	color:white;
	}
	.center-in-center{   
		position: absolute;   
		top: 50%;   
		left: 50%;   
		-webkit-transform: translate(-50%, -50%);   
		-moz-transform: translate(-50%, -50%);   
		-ms-transform: translate(-50%, -50%);   
		-o-transform: translate(-50%, -50%);   
		transform: translate(-50%, -50%);   
	}   
	.col{
		color:white;
		font-weight:bolder;
	}
</style>
</head>

<body background="pictures/言叶之庭8.png">

<div align="center" class="center-in-center">
	
	<h1 align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请完善您的相关信息:</h1>
	<form action="RegistServlet" method="post">
	
		<input type="hidden" name="action" value="regist"><br>
		
		<label>用户名:</label>
		&nbsp;&nbsp;&nbsp;
		<input type="text" name="username" required><br>
		
		<label>密码:</label>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="text" name="password" required><br>
		
		<label>确认密码:</label>
		<input type="password" name="password2" required>
		<p class="col">${message}</p>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="submit" name="regist" value="注册" style=width:75px;>
		<input type="reset" value="重置" style=width:75px;> 
	</form>
	
</div>
</body>

</html>

3.MessageList.jsp

<%@ page language="java" contentType="text/html; charset=utf-8" import="java.util.*,javaBean.Message"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>留言板系统</title>
	
	<style type="text/css">
		body {
			background-color: white;
			background-size: 100% 100%;	
			background-repeat:no-repeat; 
			background-attachment:fixed
		}
		html {
			height:100%;
			weight:100%;
		}
	</style>
</head>

<body background="pictures/言叶之庭4.jpeg">
<div align="center">
	<br>
	<h1>欢迎来到留言系统</h1>
	
	
	<table width="800" border="1" cellpadding="5">
		<%
   			 ArrayList mL=(ArrayList)request.getAttribute("MessageList");
		%>
		<tr>
			<th>留言数</th>
			<th>标题</th>
			<th>留言内容</th>
			<th>用户ID</th>
		</tr>
		<% if (mL != null){ 
		for (int i = 0; i < mL.size(); ++i ){
				Message message = (Message)mL.get(i);%>
				<tr>
					<td><%= message.getmid() %></td>
					<td><a href="MessageDetail.jsp?mid=<%= message.getmid() %>"><%= message.gettitle() %></td>	
					<td><%= message.getcontext() %></td>
					<td><%= message.getuserid() %></td>
				</tr>
		<%	} } %>
		
	</table>
	<h2><a href="LeaveMessage.jsp">我要留言</a> </h2>
</div>	
</body>
</html>

4.LeaveMessage.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>新浪微博</title>
	<style type="text/css">
		body {
			background-color: white;
			background-size: 100% 100%;	
			background-repeat:no-repeat;
评论 25
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值