I want to integrate
Struts 1.3 with Spring 3.2 and Hibernate 4.0 in a Simple user login application. I want
to use MySQL as the database. I am using Eclipse Mars as the
IDE for the development.
I already integrated Struts with Spring, it is working well, but I was unable to integrate Hibernate in the
project, please help.
Table user will be used for the database named users is as follows...
Field Type Null Key Default
---------------------------------------------------------
username varchar(30) yes no null
password varchar(40) yes no null
userid varchar(4) no PRI null
Data stored in that table is as follows...
username password userid
------------------------------------
admin admin123 1
Project structure of the application
------------------------------------------
LoginAction.java
-------------------
BusinessDelegate.java
--------------------------
LoginForm.java
------------------
ApplicationContext.xml
----------------------------
struts-config.xml
-------------------
web.xml
-----------
index.jsp
----------
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login page | Hello World Struts application in Eclipse</title>
</head>
<body>
<h1>Login</h1>
<html:form action="login">
<bean:message key="label.username"/>
<html:text property="userName"></html:text>
<html:errors property="userName" />
<br/>
<bean:message key="label.password"/>
<html:password property="password"></html:password>
<html:errors property="password"/><br/>
<html:submit/>
<html:reset/>
</html:form>
</body>
</html>
welcome.jsp
--------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome page | Hello World Struts application in Eclipse</title>
</head>
<body>
<%
String message = (String)request.getAttribute("message");
%>
<h1>Welcome <%= message %></h1>
</body>
</html>
MessageResource.properties
----------------------------------
error.username=Username is not entered
error.password=Password is not entered
label.username=Login Detail
label.password=Password
label.welcome=Welcome