简易的CRM系统案例之Struts2&Spring整合+Hibernate3+JSP+MySQL版本
主要对上一篇Struts2&Spring整合的改造
简易的CRM系统案例之Struts2+Hibernate3+JSP+MySQL版本
src/bean.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 开启注解扫描 --> <!-- 引入其他配置文件 --> <import resource="config/bean-action.xml"/>
<import resource="config/bean-dao.xml"/>
<import resource="config/bean-service.xml"/>
<import resource="config/bean-entity.xml"/> </beans>
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"> <!-- 1. struts配置 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 2. spring 配置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:bean.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <error-page>
<error-code>404</error-code>
<location>/notFoundError.jsp</location>
</error-page>
</web-app>
bean-action.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Action中需要注入Service -->
<bean id="doLogin" class="com.loaderman.crm.action.DoLoginAction" scope="prototype">
<property name="accountService" ref="accountService"></property>
<property name="account" ref="account"></property>
</bean>
<bean id="addPolicy" class="com.loaderman.crm.action.AddPolicyAciton" scope="prototype">
<property name="policyService" ref="policyService"></property>
<property name="policy" ref="policy"></property>
</bean>
<bean id="addUser" class="com.loaderman.crm.action.AddUserAction" scope="prototype">
<property name="userService" ref="userService"></property>
<property name="user" ref="user"></property> </bean>
<bean id="delUser" class="com.loaderman.crm.action.DelUserAciton" scope="prototype">
<property name="userService" ref="userService"></property>
<property name="user" ref="user"></property>
</bean>
<bean id="delPolicy" class="com.loaderman.crm.action.DelPolicyAciton" scope="prototype">
<property name="policyService" ref="policyService"></property>
<property name="policy" ref="policy"></property>
</bean>
<bean id="gtPolicyList" class="com.loaderman.crm.action.GetPolicyListAciton" scope="prototype">
<property name="policyService" ref="policyService"></property>
</bean>
<bean id="getUserList" class="com.loaderman.crm.action.GetUserListAction" scope="prototype">
<property name="userService" ref="userService"></property>
</bean> </beans>
bean-dao.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="accountDao" class="com.loaderman.crm.dao.impl.AccountDaoimp" scope="singleton" lazy-init="false">
</bean>
<bean id="policyDao" class="com.loaderman.crm.dao.impl.PolicyDaoimp" scope="singleton" lazy-init="false">
</bean>
<bean id="userDao" class="com.loaderman.crm.dao.impl.UserDaoimp" scope="singleton" lazy-init="false">
</bean> </beans>
bean-entity.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="account" class="com.loaderman.crm.entity.Account" scope="prototype" lazy-init="false">
</bean>
<bean id="user" class="com.loaderman.crm.entity.User" scope="prototype" lazy-init="false">
</bean>
<bean id="policy" class="com.loaderman.crm.entity.Policy" scope="prototype" lazy-init="false">
</bean> </beans>
bean-service.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
"> <bean id="accountService" class="com.loaderman.crm.service.impl.AccountServiceimp">
<property name="accountDao" ref="accountDao"></property> </bean>
<bean id="policyService" class="com.loaderman.crm.service.impl.PolicyServiceimp">
<property name="policyDao" ref="policyDao"></property>
</bean>
<bean id="userService" class="com.loaderman.crm.service.impl.UserServiceimp">
<property name="userDao" ref="userDao"></property>
</bean>
</beans>
请求接口演示:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!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=UTF-8">
<title>用户登录</title>
<link href="${pageContext.request.contextPath }/css/common.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function validate_form() {
var name = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (name == null || name == "") {
alert("姓名不能为空");
return false;
}
if (password == null || password == "") {
alert("密码不能为空");
return false;
}
return true; } </script>
</head>
<body>
<h2>用户登录</h2> <p><span
id="loginHit"> <%=session.getAttribute("msg") == null ? "" : session.getAttribute("msg") %><% session.removeAttribute("msg"); %></span>
</p> <form action="${pageContext.request.contextPath }/doLogin" onsubmit="return validate_form()" method="post"> <table class="loginTable"> <tr>
<td id="name">用户名:</td>
<td id="nmtd"><input type="text" name="username" id="username" value="admin"></td>
</tr> <tr>
<td id="pwd">密 码:</td>
<td id="pwdtd"><input type="password" name="password" id="password" value="admin"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="登录"></td>
</tr>
</table> </form> </body>
</html>
点击源码下载
简易的CRM系统案例之Struts2&Spring整合+Hibernate3+JSP+MySQL版本的更多相关文章
- 简易的CRM系统案例之Struts2+Hibernate3+JSP+MySQL版本
改造上一版本的DAO层 简易的CRM系统案例之Struts2+JSP+MySQL版本 src文件下hibernate.cfg.xml <!DOCTYPE hibernate-configurat ...
- 简易的CRM系统案例之Struts2+JSP+MySQL版本
对简易的CRM系统案例之Servlet+Jsp+MySQL版本改进 Servlet优化为Struts2 学习 <?xml version="1.0" encoding=&qu ...
- 简易的CRM系统案例之易的CRM系统案例之JSP+MySQL+SSH框架版本
主要对上一篇hibernate与Spring进行整合改进 简易的CRM系统案例之Struts2+Hibernate3+JSP+MySQL版本 bean-base.xml <?xml versio ...
- 简易的CRM系统案例之SpringMVC+JSP+MySQL+myBatis框架版本
主要对上一版DAO框架的替换hibernate变成myBatis 简易的CRM系统案例之SpringMVC+JSP+MySQL+hibernate框架版本 src/mybatis.xml <?x ...
- 简易的CRM系统案例之SpringMVC+JSP+MySQL+hibernate框架版本
继续对上一版本进行改版,变成SpringMVC框架 简易的CRM系统案例之易的CRM系统案例之JSP+MySQL+SSH框架版本 src/spring.xml <?xml version=&qu ...
- 简易的CRM系统案例SpringBoot + thymeleaf + MySQL + MyBatis版本
创建maven项目 pop.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns ...
- 简易的CRM系统案例之Servlet+Jsp+MySQL版本
数据库配置 datebase.properties driver=com.mysql.jdbc.Driver url=jdbc:mysql://127.0.0.1:3306/infos usernam ...
- Mybatis+struts2+spring整合
把student项目改造成ssm struts2 +mybatis+spring 1,先添加spring支持:类库三个,applicationContext.xml写在webinf下四个命名空间,监 ...
- spring基础:什么是框架,框架优势,spring优势,耦合内聚,什么是Ioc,IOC配置,set注入,第三方资源配置,综合案例spring整合mybatis实现
知识点梳理 课堂讲义 1)Spring简介 1.1)什么是框架 源自于建筑学,隶属土木工程,后发展到软件工程领域 软件工程中框架的特点: 经过验证 具有一定功能 半成品 1.2)框架的优势 提高开发效 ...
随机推荐
- Python_while语句
1.while语句: count = 0 while (count<4): count +=1 print('准备放入第'+str(count)+'个杯子') 注:还是要注意一下,条件之后加“: ...
- MySQL 数据库的高可用性分析
MySQL数据库是目前开源应用最大的关系型数据库,有海量的应用将数据存储在MySQL数据库中.存储数据的安全性和可靠性是生产数据库的关注重点.本文分析了目前采用较多的保障MySQL可用性方案. MyS ...
- brew install thrift
➜ ~ brew install thriftUpdating Homebrew...Warning: You are using macOS 10.11.We (and Apple) do not ...
- TCP/IP结构图
IP: TCP: UDP:
- CMake---基础练习1
因为卡在一个问题上,几经排除应该可能是CMakeLists.txt写的不正确,但是又生成了可执行文件,运行可执行文件报错.多方排除,应该是CMakeLists.txt加载动态库的时候,函数加载的不全. ...
- java基础(2)---基本语法
一.程序注释 二.HelloWorld 三.关键字 四.常量 五.变量 六.标识符: 七.数据类型 数据类型间的转换: (1)自主转换:不需要明确指出所要转化的类型是什么,而是由java虚拟机自动转化 ...
- c++之:new与malloc
#include <iostream> using namespace std; void spacealloc_c() { //开辟内存空间---C语言风格 int *p = (int ...
- 数位DP【模板】
经典题型 数位 DP 问题往往都是这样的题型,给定一个闭区间 $[l, r]$,让你求这个区间中满足 某种条件 的数的总数. 强烈推荐 OI Wiki——数位DP 例题 BZOJ 1026 题目:wi ...
- jquery检测屏幕宽度并跳转页面
jquery检测屏幕宽度并刷新页面 var owidth = ($(window).width()); //浏览器当前窗口可视区域宽度 if(owidth<640){//小于640跳转一个网址, ...
- [Angular 8] Custom Route Preloading with ngx-quicklink and Angular
In a previous lesson we learned about implementing a custom preloading strategy. That gives you a lo ...