功能及要求
使用Struts 2+Hibernate实现一个简单的模型
JSP+ Struts 2 +Hibernate+数据库
要求:
1、完成注册、登录、退出三个功能
2、注册校验用框架实现
3、使用Struts标签库
4、实现过滤器
(1)只能登陆成功后才能访问主页面。
5、实现拦截器功能。
(1)实现黑名单功能
6、实现文件上传功能
结构
登录页面 login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>登录页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<div align="right">
<s:a href="http://localhost:8080/StrutsTest/register.jsp">
<font color="blue"><h5>还未注册?点击注册</h5> </font>
</s:a>
</div>
<div align="left">
<h1 align="left">登录</h1>
<s:fielderror cssStyle="color:red"></s:fielderror>
<s:actionerror cssStyle="color:red"></s:actionerror>
<br>
<s:form action="login" theme="simple" method="post" validate="true">
<table border="0" style="width: 220px; height: 200px;">
<tr>
<td>用户名:</td>
<td width=20><s:textfield name="username"></s:textfield></td>
</tr>
<tr>
<td>密码:</td>
<td><s:password name="password"></s:password>
</td>
</tr>
<tr>
<td align="center"><s:submit value="登录"></s:submit>
</td>
<td align="center"><s:reset value="重置"></s:reset></td>
</tr>
</table>
</s:form>
</div>
</body>
</html>
注册页面register.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>注册页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<h1 align="center">注册</h1>
<div align="center">
<s:fielderror cssStyle="color:red"></s:fielderror>
<s:actionerror cssStyle="color:red"></s:actionerror>
<br>
<s:form action="register" theme="simple" method="post" validate="true">
<table width="50%" border="0" style="width: 501px; height: 342px;">
<tr>
<td align="right">用户名:</td>
<td width=20><s:textfield name="username"></s:textfield></td>
<td><font color="red" align="left"><h6>*必填</h6> </font></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><s:password name="password"></s:password></td>
<td><font color="red" align="left"><h6>*必填</h6> </font></td>
</tr>
<tr>
<td align="right">确认密码:</td>
<td><s:password name="repassword"></s:password></td>
<td><font color="red" align="left"><h6>*必填</h6> </font></td>
</tr>
<tr>
<td align="right">电子邮箱:</td>
<td><s:textfield name="email"></s:textfield></td>
<td><font color="red" align="left"><h6>*必填</h6> </font></td>
</tr>
<tr>
<td></td>
<td><s:submit value="提交"></s:submit> <s:reset value="重置"></s:reset>
</td>
</tr>
</table>
</s:form>
</div>
</body>
</html>
注册成功页面 register_success.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'register_success.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">