继续对上一版本进行改版,变成SpringMVC框架

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


src/spring.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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
<import resource="config/bean-base.xml"/>
<import resource="config/bean-dao.xml"/>
<import resource="config/bean-entity.xml"/> <!-- Action控制器 -->
<context:component-scan base-package="com.loaderman.crm"/> <!-- 基于注解的映射器(可选) -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/> <!-- 基于注解的适配器(可选) -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> <!-- 视图解析器(可选) -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"/> </beans>
package com.loaderman.crm.action;

import com.loaderman.crm.entity.User;
import com.loaderman.crm.service.impl.UserServiceimp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Controller
public class GetUserListAction {
@Autowired
private UserServiceimp userService; // 处理请求
@RequestMapping(value = "/getUserList")
public String getUserList(Model model, HttpServletRequest request) throws Exception {
String name = request.getParameter("name");
if ( name != null && (! name.isEmpty())) {
List<User> list = userService.getUserByName( name);
model.addAttribute("list",list);
} else {
List<User> list = userService.getAllUser();
model.addAttribute("list",list); } return "/pages/userList.jsp";
}
}
package com.loaderman.crm.action;

import com.loaderman.crm.entity.User;
import com.loaderman.crm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; @Controller
public class AddUserAction { @Autowired
private UserService userService;
@RequestMapping(value = "/addUser")
public String addUser(User user, HttpServletRequest request1) throws Exception {
System.out.println(user.toString());
String opr = request1.getParameter("opr");
int n = 0;
if (opr.equals("addUser")) {
n = userService.addUser(user);
} else if (opr.equals("modifyUser")) {
int id = Integer.parseInt(request1.getParameter("id"));
user.setId(id);
n = userService.modifyUser(user);
}
if (n > 0) {
return "redirect:getUserList.action";
} else {
return "redirect:addUser.action";
}
}
}

点击源码下载


简易的CRM系统案例之SpringMVC+JSP+MySQL+hibernate框架版本的更多相关文章

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

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

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

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

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

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

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

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

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

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

  6. 简易的CRM系统案例之Struts2&Spring整合+Hibernate3+JSP+MySQL版本

    主要对上一篇Struts2&Spring整合的改造 简易的CRM系统案例之Struts2+Hibernate3+JSP+MySQL版本 src/bean.xml <beans xmlns ...

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

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

  8. Spring注解处理Ajax请求-JSON格式[系统架构:Spring+SpringMVC+MyBatis+MySql]

    1.前端jsp页面 <div class="tab_tip"> 请输入[身份证号或姓名] <input type="text" class=& ...

  9. IDEA搭建SpringMVC+Mybatis+Mysql+Maven框架

    相关环境 Intellij IDEA Ultimate Tomcat JDK MySql 5.6(win32/win64) Maven (可使用Intellij IDEA自带的) 搭建步骤 创建项目工 ...

随机推荐

  1. WindowsPE

    什么是WindowsPE Windows Preinstallation Environment(Windows PE),Windows预引导环境,是带有有限服务的最小Win32子系统,基于以保护模式 ...

  2. python-Redis cluster基础指标监控

    #!/usr/local/python/shims/python from rediscluster import StrictRedisCluster ''' 需要在宿主机python中安装redi ...

  3. vue 监听子组件事件及组件上使用v-model

  4. [hdoj6483][莫队+线段树/ST]

    A Sequence Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  5. jquery显示隐藏密码跟显示密码

    今天讲述的是html5中input的password密码的加密与显示 都知道input标签加上password输入密码显示的都是原点.......怎么点一个按钮让他显示回来明文数字1234567 上代 ...

  6. [React + GraphQL] Use useLazyQuery to manually execute a query with Apollo React Hooks

    When using useQuery from Apollo React Hooks, the request will be sent automatically after the compon ...

  7. [Angular] Lazy Load CSS at runtime with the Angular CLI

    Ever had the need for multiple "app themes", or even to completely dynamically load CSS ba ...

  8. PHP yield占用内存测试

    function com($start) { $tmp = []; for($i=0; $i<300000; $i++){ $tmp[] = $i; } $end = memory_get_us ...

  9. MySQL 计算时间差函数 TIMESTAMPDIFF、DATEDIFF

    一.TIMESTAMPDIFF 支持天.小时.秒等 selet TIMESTAMPDIFF(hour,odl_time,now()); 计算old_time与现在时间的小时差. 二.DATEDIFF ...

  10. greenplum(postgresql) 数据字典

    greenplum是基于postgresql开发的分布式数据库,里面大部分的数据字典是一样的.我们在维护gp的时候对gp的数据字典比较熟悉,特此分享给大家.在这里不会详细介绍每个字典的内容,只会介绍常 ...