主要对上一篇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. Java--8--新特性--Lambda

    java9 都出来了,我才开始接触到java8的新特性,有点脱节啊.. Lambda是一个匿名函数,可以理解为一段可以传递的代码,将代码像数据一样传递,下面是一个小例子. public class E ...

  2. MOOC下载器的文档整理

    1.背景   最近学习中国大学MOOC的课程,想把课程的pdf下载下来本地保存并浏览.工具: Setup-Mooc-3.4.0.exe   但是,却发现所下载的文档在不同的文件夹里,浏览很不方便.于是 ...

  3. Linux CPU问题排查

    某个进程的内存占用情况 查找进程pid——>进入该进程的目录/proc/{pid}/.有三个文件记录了进程内存 root@ROUTER:~# ps | grep zebra 1507 root ...

  4. 第五次个人作业---Alpha2项目测试

    这个课程属于哪个课程 <课程的链接> 作业的要求 <作业要求的链接> 团队名称 <团队名称:六扇门编程团队> 作业的目标 从一个普通用户的角度,在测试其他团队项目的 ...

  5. 开源框架---tensorflow c++ API中./configure步骤细节

    u@u160406:~/tf1.13/tensorflow$ git checkout r1.13 分支 r1.13 设置为跟踪来自 origin 的远程分支 r1.13.切换到一个新分支 'r1.1 ...

  6. sql网址

    w3school版 https://www.w3school.com.cn/sql/index.asp 菜鸟教程版 https://www.runoob.com/sql/sql-tutorial.ht ...

  7. DataTable 删除数据后重新加载

    DataTable 删除数据后重新加载 一.总结 一句话总结: 判断datatable是否被datatable初始化或者是否执行了datatable销毁函数,如果没有,就销毁它 if ($('#dat ...

  8. Bcompare 提示 “这个授权密钥已被吊销” 解决方法

    Bcompare 提示 “这个授权密钥已被吊销” 解决方法 打开文件夹 %appdata%\Scooter Software 找到相应的版本,例如 Beyond Compare 3 删除里面的 BCS ...

  9. 【转】Senior Data Structure · 浅谈线段树(Segment Tree)

    本文章转自洛谷 原作者: _皎月半洒花 一.简介线段树 ps: _此处以询问区间和为例.实际上线段树可以处理很多符合结合律的操作.(比如说加法,a[1]+a[2]+a[3]+a[4]=(a[1]+a[ ...

  10. 神经网络(1)--Non-linear hypotheses,为什么我们要学习神经网络这种算法来处理non-linear hypotheses

    神经网络(1)--No-linear hypotheses 为什么我们已经有了linear regression与logistic regression算法还要来学习神经网络这个另外的算法呢,让我们来 ...