主要对上一篇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. Yum三方仓库——EPEL

    参考:什么是EPEL 及 Centos上安装EPEL 参考:How to Enable EPEL Repository for RHEL/CentOS 7.x/6.x/5.x 前言 RHEL以及他的衍 ...

  2. jmeter+jenkins 配置过程(很详细)

    一.安装jmeter 第一步  安装JDK,配置JDK路径.注:jdk下载地址,推荐使用jdk1.8版本 http://www.oracle.com/technetwork/java/javase/d ...

  3. java项目中注解使用——整理

    文章:@Mapper注解的使用 地址:https://blog.csdn.net/weixin_39666581/article/details/81057385 @Mapper注解的的作用 1:为了 ...

  4. Java学习笔记——第3篇

    面向对象 结构化程序的任何一个结构都具有唯一的入口和唯一的出口,并且程序不会出现死循环. 虽然Java是面向对象的,但Java的方法里则是一种结构化的程序流. 面向对象的基本思想:类.对象.继承.封装 ...

  5. sublimerge

    Package Control Messages======================== Sublimerge 3------------ Sublimerge 3 (beta) has ju ...

  6. ASP.NET MVC 入门5、View与ViewData

    View建立时有MVC View Page 和 MVC View Content Page两种类型, 前者为标准View, 后者为可继承Master母版页的View. Asp.Net MVC 默认使用 ...

  7. xld特征

    halcon中什么是xld? xld(eXtended Line Descriptions) 扩展的线性描述,它不是基于像素的,人们称它是亚像素,只不过比像素更精确罢了,可以精确到像素内部的一种描述. ...

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

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

  9. js 实现多文件批量下载

    关于兼容性问题: <a href="xxx.docx" target='_blank'></a> 下载文件时,这种写法是没有兼容性问题:但是下载图片时,IE ...

  10. Generator(生成器)函数

    一.基础知识 Generator函数是ES6出现的一种异步操作实现方案. 异步即代码分两段,但是不是连续执行,第一段执行完后,去执行其他代码,等条件允许,再执行第二段. 同步即代码连续执行. 1. G ...