功能及要求

使用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">-->
<title>注册成功</title>
<script language='javascript' type='text/javascript'>var secs = 5; //倒计时的秒数     var URL;function Load(url) {URL = url;for ( var i = secs; i >= 0; i--) {window.setTimeout('doUpdate(' + i + ')', (secs - i) * 1000);}}function doUpdate(num) {document.getElementById('ShowDiv').innerHTML = '将在' + num+ '秒后自动跳转到登录页面';if (num == 0) {window.location = URL;}}
</script>
</head>
<body><center><h1><font color="red" align="center">恭喜您,注册成功!!</font></h1><br /><div id="ShowDiv"></div><script language="javascript">Load("http://localhost:8080/StrutsTest/login.jsp");</script><s:a href="http://localhost:8080/StrutsTest/login.jsp"><font color="blue"><h5>手动登录?</h5> </font></s:a></center>
</body>
</html>

上传文件 upload.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 + "/";
%>
<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><s:form action="uploadfile.action" method="post"enctype="multipart/form-data"><div align="left"><s:file name="upload" label="上传的文件"></s:file><div><s:submit value="上传"></s:submit></div></div></s:form>
</body>
</html>

**

文件上传成功界面 upload_success.jsp

<%@ page language="java"  pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>成功页面</title></head><body><div>恭喜你!上传成功</div><div style=" float:right;"><a href="http://localhost:8080/StrutsTest/upload.jsp">退出 </body>
</html>

欢迎界面 welcome.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%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><div style="float:left;"><font align="right" color="blue">欢迎您!${userName}</font><!-- ${userName} <s:property value="#request.name" /> --></div><div style=" float:right;"><a href="http://localhost:8080/StrutsTest/upload.jsp" style="text-decoration: none;">上传文件<a href="http://localhost:8080/StrutsTest/login.jsp">退出 </div></div>
</body>
</html>

TableUser.java

注:使用Hibernate导出

package org.hiber;/*** TableUser entity. @author MyEclipse Persistence Tools*/public class TableUser implements java.io.Serializable {// Fieldsprivate String name;private String password;private String email;// Constructors/** default constructor */public TableUser() {}/** full constructor */public TableUser(String name, String password, String email) {this.name = name;this.password = password;this.email = email;}// Property accessorspublic String getName() {return this.name;}public void setName(String name) {this.name = name;}public String getPassword() {return this.password;}public void setPassword(String password) {this.password = password;}public String getEmail() {return this.email;}public void setEmail(String email) {this.email = email;}
}

TableUser.hbm.xml(自动生成)

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping><class name="org.hiber.TableUser" table="TABLE_USER" schema="dbo" catalog="JavaEE"><id name="name" type="java.lang.String"><column name="Name" length="20" /><generator class="assigned" /></id><property name="password" type="java.lang.String"><column name="Password" length="50" not-null="true" /></property><property name="email" type="java.lang.String"><column name="Email" length="50" not-null="true" /></property></class>
</hibernate-mapping>

HibernateSessionFactory.java(自动生成)

package org.hiber;import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;/*** Configures and provides access to Hibernate sessions, tied to the* current thread of execution.  Follows the Thread Local Session* pattern, see {@link http://hibernate.org/42.html }.*/
public class HibernateSessionFactory {/** * Location of hibernate.cfg.xml file.* Location should be on the classpath as Hibernate uses  * #resourceAsStream style lookup for its configuration file. * The default classpath location of the hibernate config file is * in the default package. Use #setConfigFile() to update * the location of the configuration file for the current session.   */private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();private  static Configuration configuration = new Configuration();    private static org.hibernate.SessionFactory sessionFactory;private static String configFile = CONFIG_FILE_LOCATION;static {try {configuration.configure(configFile);sessionFactory = configuration.buildSessionFactory();} catch (Exception e) {System.err.println("%%%% Error Creating SessionFactory %%%%");e.printStackTrace();}}private HibernateSessionFactory() {}/*** Returns the ThreadLocal Session instance.  Lazy initialize* the <code>SessionFactory</code> if needed.**  @return Session*  @throws HibernateException*/public static Session getSession() throws HibernateException {Session session = (Session) threadLocal.get();if (session == null || !session.isOpen()) {if (sessionFactory == null) {rebuildSessionFactory();}session = (sessionFactory != null) ? sessionFactory.openSession(): null;threadLocal.set(session);}return session;}/***  Rebuild hibernate session factory**/public static void rebuildSessionFactory() {try {configuration.configure(configFile);sessionFactory = configuration.buildSessionFactory();} catch (Exception e) {System.err.println("%%%% Error Creating SessionFactory %%%%");e.printStackTrace();}}/***  Close the single hibernate session instance.**  @throws HibernateException*/public static void closeSession() throws HibernateException {Session session = (Session) threadLocal.get();threadLocal.set(null);if (session != null) {session.close();}}/***  return session factory**/public static org.hibernate.SessionFactory getSessionFactory() {return sessionFactory;}/***  return session factory**  session factory will be rebuilded in the next call*/public static void setConfigFile(String configFile) {HibernateSessionFactory.configFile = configFile;sessionFactory = null;}/***  return hibernate configuration**/public static Configuration getConfiguration() {return configuration;}
}

hibernate.cfg.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate Configuration DTD 3.0//EN""http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration><session-factory><property name="dialect">org.hibernate.dialect.SQLServerDialect</property><property name="connection.url">jdbc:sqlserver://127.0.0.1:1433;DatabaseName=JavaEE</property><property name="connection.username">sa</property><property name="connection.password">1436956104</property><property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property><property name="myeclipse.connection.profile">JavaEE</property><!-- 需要有这句话,若文件中没有自动生成这句话,需要自己写入 --><mapping resource="org/hiber/TableUser.hbm.xml" /></session-factory></hibernate-configuration>

UserDao.java

package org.javabean;import java.util.Iterator;
import java.util.List;import org.hiber.HibernateSessionFactory;
import org.hiber.TableUser;
import org.hibernate.*;public class UserDao {// 执行数据库查询并返回查询结果,登录查询使用,判断用户是否存在public TableUser loginQuery(String username, String password) {TableUser tableUser = new TableUser();// 创建POJO类对象try {// 调用HibernateSessionFactory的getSession方法创建Session对象Session session = HibernateSessionFactory.getSession();// 创建事务对象Transaction ts = session.beginTransaction();Query query = session.createQuery("from TableUser where Name=? and Password=?");query.setString(0, username);query.setString(1, password);List list = query.list();// if (list != null) {//// }/** List.iterator()方法用于返回按适当顺序在列表的元素上进行迭代的迭代器。 方法返回值为Iterator 对象。*/Iterator iterator = list.iterator();while (iterator.hasNext()) {tableUser = (TableUser) iterator.next();System.out.println("登录查询:" + tableUser.getName() + ";"+ tableUser.getPassword());}} catch (Exception ex) {ex.printStackTrace();System.out.println("查询失败");}return tableUser;}// 执行数据库查询数据,注册查询使用,查询是否存在相同的用户名public boolean NameAlreadyExists(String username) {TableUser tableUser = new TableUser();// 创建POJO类对象try {// 调用HibernateSessionFactory的getSession方法创建Session对象Session session = HibernateSessionFactory.getSession();// 创建事务对象Transaction ts = session.beginTransaction();Query query = session.createQuery("from TableUser where Name = ?");query.setParameter(0, username);List list = query.list();/** List.iterator()方法用于返回按适当顺序在列表的元素上进行迭代的迭代器。 方法返回值为Iterator对象。*/Iterator iterator = list.iterator();while (iterator.hasNext()) {tableUser = (TableUser) iterator.next();System.out.println("用户名重复查询:" + tableUser.getName() + ";");return true;}} catch (Exception ex) {ex.printStackTrace();System.out.println("查询失败");}return false;}// 数据库添加数据public void insert(TableUser user) {try {// 调用HibernateSessionFactory的getSession方法创建Session对象Session session = HibernateSessionFactory.getSession();// 创建事务对象Transaction ts = session.beginTransaction();session.save(user);ts.commit();System.out.println("插入成功");} catch (final Exception e) {// TODO: handle exceptione.printStackTrace();System.out.println("插入失败");}}
}

LoginAction.java

package org.action;import java.util.Map;import org.javabean.UserDao;
import org.hiber.*;import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;public class LoginAction extends ActionSupport {String username;String password;public String getUsername() {return username;}public void setUsername(final String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(final String password) {this.password = password;}@Overridepublic String execute() throws Exception {UserDao userDao = new UserDao();TableUser user = new TableUser();user = userDao.loginQuery(username, password);System.out.println(user.getName());if (user.getName() == null) {this.addFieldError("username", "用户名或密码错误!");return INPUT;} else {ActionContext actionContext = ActionContext.getContext();Map session = actionContext.getSession();session.put("userName", user.getName());// Map request = (Map) ActionContext.getContext().get("request");// request.put("name", user.getUsername());return SUCCESS;}}
}

RegisterAction.java

package org.action;import java.util.Map;import org.hiber.*;
import org.javabean.UserDao;import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;public class RegisterAction extends ActionSupport {private static final long serialVersionUID = 1L;private String username;private String password;private String repassword;private String email;public String getRepassword() {return repassword;}public void setRepassword(String repassword) {this.repassword = repassword;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}@Overridepublic String execute() throws Exception {TableUser user = new TableUser();user.setName(username);user.setPassword(password);user.setEmail(email);UserDao userDao = new UserDao();if (userDao.NameAlreadyExists(username)) {this.addFieldError(username, "该用户名已存在");return INPUT;} else {userDao.insert(user);return SUCCESS;}}//// @Override// public void validate() {// ActionContext actionContext = ActionContext.getContext();// Map session = actionContext.getSession();// if (!repassword.equals(password)) {// this.addFieldError(repassword, "密码不一致");// }// }}

UpLoadAction.java

package org.action;import java.io.*;import javax.servlet.ServletContext;import org.apache.struts2.ServletActionContext;import com.opensymphony.xwork2.ActionSupport;public class UpLoadAction extends ActionSupport {private File upload;                                //上传文件private String uploadFileName;                        //上传的文件名public File getUpload() {return upload;}public void setUpload(File upload) {this.upload=upload;}@Overridepublic String execute() throws Exception {// TODO Auto-generated method stubInputStream is=new FileInputStream(getUpload());    //根据上传的文件得到输入流OutputStream os=new FileOutputStream("d:\\upload\\"+uploadFileName);  //指定输出流地址byte buffer[]=new byte[5242880];   int count=0;while((count=is.read(buffer))>0){os.write(buffer,0,count);                        //把文件写到指定位置的文件中}os.close();                                     //关闭is.close();return SUCCESS;                                  //返回}public String getUploadFileName() {return uploadFileName;}public void setUploadFileName(String uploadFileName) {this.uploadFileName=uploadFileName;}
}

登录校验 LoginAction-validation.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC"-//Apache Struts//XWork Validator 1.0.3//EN""http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"><validators><field name="username"><field-validator type="requiredstring"><param name="trim">true</param><message>账号不能为空!</message></field-validator></field><field name="password"><field-validator type="requiredstring"><param name="trim">true</param><message>密码不能为空!</message></field-validator></field>
</validators>

注册校验 RegisterAction-validation.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC"-//Apache Struts//XWork Validator 1.0.3//EN""http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"><validators><field name="username"><field-validator type="requiredstring"><param name="trim">true</param><message>账号不能为空</message></field-validator></field><field name="password"><field-validator type="requiredstring" short-circuit="true"><param name="trim">true</param><message>密码不能为空</message></field-validator><field-validator type="stringlength"><param name="minLength">1</param><param name="maxLength">20</param><message>密码长度应在 1 ~ 20之间</message></field-validator></field><field name="email"><field-validator type="requiredstring" short-circuit="true"><param name="trim">true</param><message>邮箱不能为空</message></field-validator><field-validator type="email"><message>邮箱输入不正确</message></field-validator></field><field name="repassword"><field-validator type="fieldexpression"><param name="expression"><![CDATA[(password==repassword)]]></param><message>两次密码必须相同!!</message></field-validator></field><!-- <field name="repassword"> <field-validator type="fieldexpression"> <param name="expression"><![CDATA[(password==repassword)]]></param> <message>两次密码必须相同!!</message> </field-validator> </field> -->
</validators>

拦截器LoginInterceptor.java

package org.interceptor;import java.util.Map;import javax.mail.MessageAware;
import javax.mail.Session;import org.action.LoginAction;import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;public class LoginInterceptor extends AbstractInterceptor {@Overridepublic String intercept(ActionInvocation actionInvocation) throws Exception {// TODO Auto-generated method stubObject action = actionInvocation.getAction();// 获取Action实例if (action != null) {// 如果action是LoginActionif (action instanceof LoginAction) {// 类型转换LoginAction loginAction = (LoginAction) action;// 获取内容String content = loginAction.getUsername();if (content.indexOf("hello") != -1) {return "error";}return actionInvocation.invoke(); // 调用invoke方法,程序通过此拦截器} else {return "success";}}return "success";}
}

过滤器SetLoginFilter.java

package org.interceptor;import java.io.IOException;
import java.io.PrintWriter;import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.FilterChain;public class SetLoginFilter implements Filter {public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {HttpServletRequest servletRequest = (HttpServletRequest) request;HttpServletResponse servletResponse = (HttpServletResponse) response;HttpSession session = servletRequest.getSession();// 获得用户请求的URIString path = servletRequest.getRequestURI();System.out.println("用户请求的URI:" + path);String username = (String) session.getAttribute("userName");System.out.println(username);// 登陆页面无需过滤if (path.indexOf("/login.jsp") > -1) {chain.doFilter(servletRequest, servletResponse);return;}// 判断如果没有取到用户信息,就跳转到登陆页面if (username == null || username.equals("")) {// 跳转到登陆页面servletResponse.sendRedirect(servletRequest.getContextPath()+ "/login.jsp");} else {// 已经登陆,继续此次请求chain.doFilter(request, response);}}public void init(FilterConfig arg0) throws ServletException {// TODO Auto-generated method stubSystem.out.println("过滤器初始化...");}public void destroy() {// TODO Auto-generated method stubSystem.out.println("销毁过滤器...");}}

struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN""http://struts.apache.org/dtds/struts-2.0.dtd"><struts><constant name="struts.multipart.saveDir" value="/upload"/><package name="default" extends="struts-default"><interceptors><interceptor name="LoginInterceptor" class="org.interceptor.LoginInterceptor"></interceptor></interceptors><action name="register" class="org.action.RegisterAction"><result name="success">/register_success.jsp</result><result name="input">/register.jsp</result></action><action name="uploadfile" class="org.action.UpLoadAction"><result name="success">/upload_success.jsp</result></action><action name="login" class="org.action.LoginAction"><result name="success" type="redirect">/welcome.jsp</result><result name="input">/login.jsp</result><result name="error">/login.jsp</result><!-- 先进行过滤,在跳转页面 --><interceptor-ref name="defaultStack"></interceptor-ref><interceptor-ref name="LoginInterceptor"></interceptor-ref></action></package>
</struts>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><filter><filter-name>SetLoginFilter</filter-name><filter-class>org.interceptor.SetLoginFilter</filter-class></filter><filter-mapping><filter-name>SetLoginFilter</filter-name><!--过滤站点下所有文件, 也可设置成过滤某一类文件如: "*.jsp" 或是过滤掉某一个文件夹下的所有文件,如: "/目录名/*" --><url-pattern>/welcome.jsp</url-pattern></filter-mapping><filter><filter-name>strutsTest</filter-name><filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>strutsTest</filter-name><url-pattern>/*</url-pattern></filter-mapping>
</web-app>

结果

登录:注册:

上传文件:

Struts2+Hibernate相关推荐

  1. Struts2+Hibernate+Spring 整合示例

    转自:https://blog.csdn.net/tkd03072010/article/details/7468769 Struts2+Hibernate+Spring 整合示例 Spring整合S ...

  2. Struts2+Hibernate分页显示实例

    下面是一个struts2+hibernate的分页显示,主要是用到了hibernate的相应分页方法大大简单了分页的代码 版本:Struts2.1.8 Hibernate3.2 Oracle9g 具体 ...

  3. 【struts2+hibernate+spring项目实战】实现用户登录功能(ssh)

    一.概述 从今天才开始有时间来总结总结以前自己练习的一些东西,希望总结出来对以后可以更加便捷的来学习,也希望可以帮助到正需要这些东西的同行人,一起学习,共同进步. 二. 登录功能总结 2.1.登录功能 ...

  4. 实践hibernate的应用——struts2+hibernate的简单学生信息管理

    struts2+hibernate的简单学生信息管理,没有用很好的界面,目的主要是为了实践一下hibernate框架的学习,深入了解hibernate框架. 下面是项目的目录: 配置文件hiberna ...

  5. SSH(Struts2+Hibernate+Spring)开发策略

    很多小伙伴可能一听到框架两个字就会马上摇头,脑子里立刻闪现一个词---"拒绝",其实我也不例外,但我想告诉大家的是,当你真正掌握它时,你会发现**SSH**用起来是那么顺手,因为它 ...

  6. jsp管理系统页面模板_jsp+ssh(spring+struts2+hibernate)+mysql实现的高校实验室管理系统...

    今天给大家演示的是一款由 jsp+ssh(spring+struts2+hibernate)+mysql实现的 高校实验室管理系统 本系统后端采用ssh框架, 前端采用bootstrap和layui框 ...

  7. Struts2 Hibernate集成示例教程

    Struts2 Hibernate集成示例教程 Struts2和Hibernate都是各自领域中广泛使用的框架.今天我们将学习如何将Struts2 Web应用程序框架与Hibernate ORM框架集 ...

  8. struts2+hibernate+spring配置详解

    #struts2+hibernate+spring配置详解 struts2+hibernate+spring配置详解 哎 ,当初一个人做好难,现在终于弄好了,希望自学这个的能少走些弯路. 以下是自己配 ...

  9. java ee ssh三大框架知识点_详解JAVAEE——SSH三大框架整合(spring+struts2+hibernate)...

    详解JAVAEE--SSH三大框架整合(spring+struts2+hibernate) 发布时间:2020-09-17 13:34:05 来源:脚本之家 阅读:64 作者:kent鹏 一.整合原理 ...

  10. Struts2 + Hibernate + Spring 以及javaweb模块问题解决(1)

    Struts2 + Hibernate + Spring 以及javaweb模块问题解决 1.资源文件的配置:src文件夹里面要配置,action所在的目录中也要配置. 2.<s: action ...

最新文章

  1. 【Python算法】哈希存储、哈希表、散列表原理
  2. linux端口命令是什么意思,cmd和linux的查看端口命令是什么?
  3. qq ip探测仪 php,巧用Win7资源监视器,查看QQ好友IP
  4. 01.最简单的helloworld
  5. 学习笔记:CentOS7学习之十八:Linux系统启动原理及故障排除
  6. slim.conv2d以及slim.convolution2d与tf.nn.conv2d的不同
  7. 实数系的基本定理_11、实数的连续性(1)
  8. C#:合并EXCEL文件工作表列
  9. 数据报表开发技巧:自动为数据报表添加【小计】、【总计】行
  10. react项目—单击按钮返回上一页
  11. 1660用哪个驱动稳定_3DS MAX哪个版本更稳定更好用?各个版本来分析
  12. 【西电—英美国家概况(英美概况/英美文化)2023第一学期】第十章参考课后答案
  13. 题目:对给定10个国家名,按字母顺序输出
  14. NBU:1651 Red packet(二分)【好】
  15. QT 绘图橡皮擦效果的实现
  16. linux下打印机监控,Linux下控制打印机笔记
  17. 2022哈工大软件构造我的学习笔记(1)
  18. IAR 配置ICF跟项目走
  19. 广东中考数学不允许使用计算机,上070821对苏州市数学中考两次禁用计算器的反思终稿.doc...
  20. Markdown 如何让图片居中

热门文章

  1. windows 2003 下的 apache(2.2.23)+tomcat(7.0.35)+p...
  2. Landsat Tm5辐射定标和大气校正(转)
  3. 最新酷狗音乐反爬来袭,Python掌握酷狗排行榜加密规则
  4. 1089. 狼人杀-简单版 (20 分)
  5. 后盾网-CI框架实例教程-马振宇 - 学习笔记(8)
  6. 根据 excel 模板自定义导出excel
  7. 头歌 软件测试项目综合实训 答案 有目录善用目录 持续更新
  8. tcc803x spi驱动解析
  9. 安徽省政府采购网逆向分析
  10. 深入浅出讲解h5棋牌开发的socket通信