主要对上一篇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">密&nbsp;&nbsp;&nbsp;&nbsp;码:</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版本的更多相关文章

  1. 简易的CRM系统案例之Struts2+Hibernate3+JSP+MySQL版本

    改造上一版本的DAO层 简易的CRM系统案例之Struts2+JSP+MySQL版本 src文件下hibernate.cfg.xml <!DOCTYPE hibernate-configurat ...

  2. 简易的CRM系统案例之Struts2+JSP+MySQL版本

    对简易的CRM系统案例之Servlet+Jsp+MySQL版本改进 Servlet优化为Struts2 学习 <?xml version="1.0" encoding=&qu ...

  3. 简易的CRM系统案例之易的CRM系统案例之JSP+MySQL+SSH框架版本

    主要对上一篇hibernate与Spring进行整合改进 简易的CRM系统案例之Struts2+Hibernate3+JSP+MySQL版本 bean-base.xml <?xml versio ...

  4. 简易的CRM系统案例之SpringMVC+JSP+MySQL+myBatis框架版本

    主要对上一版DAO框架的替换hibernate变成myBatis 简易的CRM系统案例之SpringMVC+JSP+MySQL+hibernate框架版本 src/mybatis.xml <?x ...

  5. 简易的CRM系统案例之SpringMVC+JSP+MySQL+hibernate框架版本

    继续对上一版本进行改版,变成SpringMVC框架 简易的CRM系统案例之易的CRM系统案例之JSP+MySQL+SSH框架版本 src/spring.xml <?xml version=&qu ...

  6. 简易的CRM系统案例SpringBoot + thymeleaf + MySQL + MyBatis版本

    创建maven项目 pop.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns ...

  7. 简易的CRM系统案例之Servlet+Jsp+MySQL版本

    数据库配置 datebase.properties driver=com.mysql.jdbc.Driver url=jdbc:mysql://127.0.0.1:3306/infos usernam ...

  8. Mybatis+struts2+spring整合

    把student项目改造成ssm  struts2 +mybatis+spring 1,先添加spring支持:类库三个,applicationContext.xml写在webinf下四个命名空间,监 ...

  9. spring基础:什么是框架,框架优势,spring优势,耦合内聚,什么是Ioc,IOC配置,set注入,第三方资源配置,综合案例spring整合mybatis实现

    知识点梳理 课堂讲义 1)Spring简介 1.1)什么是框架 源自于建筑学,隶属土木工程,后发展到软件工程领域 软件工程中框架的特点: 经过验证 具有一定功能 半成品 1.2)框架的优势 提高开发效 ...

随机推荐

  1. python中字符串离散化的例子

    ''' 问题:1.假设DataFrame中有一列名为type,其字段中内容为a,b,c 等用,隔开的值,如: type a,b,c a,f,x b,c,e ...统计type中每个类型出现的次数 并绘 ...

  2. centOS7 下 安装mysql8.x

    第一部分 CentOS7安装mysql1.1 安装前清理工作:1.1.1 清理原有的mysql数据库:使用以下命令查找出安装的mysql软件包和依赖包: rpm -pa | grep mysql 显示 ...

  3. flask中使用ajax 处理前端请求,每隔一段时间请求不通的接口,结果展示同一页面

    需求: flask中使用ajax 处理前端请求,每隔一段时间请求不通的接口,结果展示同一页面 用到 setTimeout方法,setTimeout(function(){},1000):setTime ...

  4. python_面向对象——类方法和静态方法

    1.类方法不能访问实例变量,只能访问类变量. class Dog(object): name = 'wdc' def __init__(self,name): self.name = name def ...

  5. python_面向对象——编程步骤

    校园管理系统: 设计一个学校机构管理系统,有总部.分校.有学院.老师.员工,实现具体如下需求: 1.有多个课程,课程要有定价 2.有多个班级,班级跟课程有关联 3.有多个学生,学生报名班级,交这个班级 ...

  6. 备份MySQL数据库并上传到阿里云OSS存储

    1. 环境配置 要将本地文件上传到阿里云oss中, 必须使用阿里云提供的工具 ossutil, 有32位,也有64位的, Linux和Windows都有.具体可以到阿里云官网下载 官网及文档: htt ...

  7. Spring Cloud Eureka 注册中心高可用机制

    一.Eureka 正常工作流程 Service 服务作为 Eureka Client 客户端需要在启动的时候就要向 Eureka Server 注册中心进行注册,并获取最新的服务列表数据. Eurek ...

  8. Vue项目中v-bind动态绑定src路径不成功

    问题: 在做Vue项目的时候,由于项目需求,需要动态绑定img的src时,突然发现如果说是直接请求后台接口的图片地址就能显示, 但是直接动态绑定img的src的图片的相对路径或者是绝对路径的时候,图片 ...

  9. HDU-1573-X问题(线性同余方程组)

    链接: https://vjudge.net/problem/HDU-1573 题意: 求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1] ...

  10. 简单js的介绍

    JavaScript 简介 JavaScript 是世界上最流行的编程语言. 这门语言可用于 HTML 和 web,更可广泛用于服务器.PC.笔记本电脑.平板电脑和智能手机等设备. JavaScrip ...