zoukankan      html  css  js  c++  java
  • 简易的CRM系统案例之SpringMVC+JSP+MySQL+hibernate框架版本

    继续对上一版本进行改版,变成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";
        }
        }
    }

    点击源码下载


  • 相关阅读:
    C#字符串的比较
    C#字符串分割
    [Android] Android 卡片式控件CardView的优雅使用
    [Android] Android Studio 使用config.gradle统一管理项目的依赖库
    [Android] Android Studio 修改Gradle使用国内源
    [Android] Sqlite 数据库操作 工具封装类
    [Android] Android 去掉界面标题栏的方法
    [Android] Android RecycleView和ListView 自定义Adapter封装类
    [Android] Android 让UI控件固定于底部的几种方法
    [Android] Android读取Asset下文件的最简单的方法总结(用于MediaPlayer中)
  • 原文地址:https://www.cnblogs.com/loaderman/p/10303734.html
Copyright © 2011-2022 走看看