目录
3.4. 修改 Spring 配置文件 applicationContext.xml
4.2. 创建 MyEclipse 数据库驱动(DB Driver)
4.7. 修改Spring配制文件 applicationContext.xml
Struts1.2+Spring2.5+Hibernate3.2框架搭建
工具:MyEclipse 8.0 GA、Tomcat 6.0
环境:Struts1.2、Spring2.5、Hibernate3.2、sqlserver2000
com.zlk.business业务层接口类
com.zlk.business.impl业务层实现类
com.zlk.dao数据层接口类
com.zlk.dao.impl数据层实现类
com.struts.action控制层
com.struts.form
操作:[右击项目] MyEclipse /Add Struts Capabilities
操作:修改struts类所在的包
2.2.创建 ActionForm 类
操作:[打开struts的设计页面,右击] New/Form,Action,and JSP
类名:LoginForm
在 "Form Properties" 选项卡为 loginForm 新增两个属性:username、password;
2.3. 创建 Action 类
类名:LoginAction
在“Parameter选项卡”中把Parameter的值设置成“methods”
2.4. 创建jsp 文件
index.jsp代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
response.sendRedirect(request.getContextPath()+"/login.jsp");
%>
login.jsp代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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 'login.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">
-->
</head>
<body>
SSH框架搭建测试——登陆.
<br>
<form action="<%=request.getContextPath()%>/login.do?methods=login"
method="post">
<input type="text" name="username">
<br />
<input type="password" name="password">
<br />
<input type="submit" value="登陆">
<input type="button" value="注册" onclick="window.location.href='<%=request.getContextPath() %>/register.jsp'">
</form>
</body>
</html>