关于SpringMVC+Spring+Mybatis+JQuery+BootStrap_Table的Maven项目

关于SpringMVC与Spring结合Mybatis的Maven项目

各类文件位置

关于SpringMVC+Spring+Mybatis+JQuery+BootStrap_Table的Maven项目_第1张图片
关于SpringMVC+Spring+Mybatis+JQuery+BootStrap_Table的Maven项目_第2张图片
关于SpringMVC+Spring+Mybatis+JQuery+BootStrap_Table的Maven项目_第3张图片

简单的POM.xml配置


	4.0.0
	com.johe.scgcxx
	com.scgcxx
	0.0.1-SNAPSHOT
	war

	
		
		
			javax.servlet
			javax.servlet-api
			3.1.0
			provided
		

		
		
			org.springframework
			spring-context
			5.1.4.RELEASE
		

		
		
			org.springframework
			spring-webmvc
			5.1.4.RELEASE
		

		
		
			com.fasterxml.jackson.core
			jackson-databind
			2.9.8
		
		
		
			org.springframework
			spring-jdbc
			5.1.4.RELEASE
		

		
		
			org.aspectj
			aspectjweaver
			1.9.2
		

		
		
			org.mybatis
			mybatis
			3.5.0
		

		
		
			org.mybatis
			mybatis-spring
			2.0.0
		


		
		
			com.alibaba
			druid
			1.1.12
		

		
		
			mysql
			mysql-connector-java
			5.1.47
		

		
		
			com.oracle
			ojdbc6
			12.1.0.1-atlassian-hosted
		

		
		
			jstl
			jstl
			1.2
		

		
		
			taglibs
			standard
			1.1.2
		

		
		
			org.apache.logging.log4j
			log4j-core
			2.11.1
		

		
		
			com.github.pagehelper
			pagehelper
			5.1.8
		

	

	

		
			
				org.apache.maven.plugins
				maven-compiler-plugin
				3.8.0
				
					1.8
					1.8
				
			
		

	

WEB.xml配置



	com.scgcxx
	
		index.html
		index.htm
		index.jsp
		default.html
		default.htm
		default.jsp
	

	
	
		characterEncodingFilter
		org.springframework.web.filter.CharacterEncodingFilter
		
			encoding
			UTF-8
		
		
			forceEncoding
			true
		
	
	
		characterEncodingFilter
		/*
	
	
	
		org.springframework.web.context.ContextLoaderListener
	

	
	
		contextConfigLocation
		/WEB-INF/spring-*.xml
	

	
	
		springmvc
		org.springframework.web.servlet.DispatcherServlet
		
			contextConfigLocation
			/WEB-INF/mvc-servlet.xml
		
		1
	

	
		springmvc
		/
	


Spring-MVC.xml配置




	
	
	  
	
	
	
	
	 
	
	
	    
	    
	    
	


Spring-TX.xml事务配置





	
	
	
	
    
        
    


Spring-Dao.xml配置




	
	
		
        
        
        
		    
		      
		        
		          
		          
		            helperDialect=oracle
		            reasonable=true
		          
		        
		      
		    
	  
        
        
    

	
	
		
	
	
	

Spring-DS.xml数据源配置




	
	
		
        
		
		

		

		
		
		
		

		
		

		
		
		

		
		

		
	


Spring-Service.xml配置




	
	

数据展示页面 JSP

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.util.*,com.johe.scgcxx.model.*"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


	
	
	花色号维护
	
	
	
	
	
	
	

	
		
    

数据添加页面JSP

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>





花色新增

	
	
	




	

数据修改页面JSP

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="com.johe.scgcxx.model.*,java.util.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>





花色修改







	

自定义BootStrap_Table需求JS

/* 员工信息关于BootStrap_Table 的显示 */
$(function() {
    $('#table').bootstrapTable({
        url: 'getPageList', // 请求路径
        method: 'get', // 请求方式
        toolbar:'#btn-toolbar',// 自定义工具栏 自定义DOM
        striped: true, // 隔行换色
        pagination: true, // 是否显示分页
        sortable: true, // 排序
        sortName: 'co_id', // 排序字段
        sortOrder: 'asc', // 排序方式
        // search: true, //是否显示表格搜索
        sidePagination: 'server', // 分页方式client客户端 ,server服务端
        pageSize: 3, // 初始化显示记录数 默认10
        pageList: [3, 5, 10, 20], // 供选择的分页行数
        paginationSuccessivelySize:2,// 允许最大连续页数
        // paginationUseIntermediate:true,//计算显示中间页
        // showToggle: true, //显示详细视图 和 列表视图切换
        // showRefresh: true, //是否显示刷新按钮
        // showColumns: true, //显示 选择列 展示按钮
        // showPaginationSwitch: true, //是否显示分页
        silentShort:true,
        columns: [{
            checkbox: true,
            visible: true
        }, {
            field: "co_id",
            title: "花色编号"
        }, {
            field: 'co_name',
            title: '花色名'
        }, {
            field: 'co_remark',
            title: '花色备注',
        }, {
            field: 'co_id',
            title: '操作',
            align: 'center',
            valign: 'middle',
            formatter: actionFormatter
        }],
        onLoadSuccess: () => {
        	toUpd();
        	doDel();
        },
        onDBlClickRow(row, $element) {
            // var id = row.d_id;
        },
        queryParams:function(params) {
        	// 分页参数
        	
        	// 模糊查询时需求参数
        	params['co_id']=$('input[name=co_id]').val();
        	params['co_name']=$('input[name=co_name]').val();
        	params['co_remark']=$('input[name=co_remark]').val();
        	
        	return params;
        }
    });
});
$(function(){
    $("button[type=button][name=btn-delAll]").click(function () {
    	var rows = $("#table").bootstrapTable('getSelections', function (row) {
            return row;
    	});
    	if (rows.length== 0) {
    	        alert("请先选择要删除的记录!");
    	        return;
    	}
    	var co_ids = '';
        for (var i = 0; i < rows.length; i++) {
        	co_ids += rows[i].co_id + ",";
        }
        co_ids = co_ids.substring(0, co_ids.length - 1);
    	doDelAll(co_ids);
    });
});
// 关于编辑菜单的按钮
function actionFormatter(value, row, index) {
    var id = value;
    var status = row.d_status;
    var result = "";
    result += "  ";
    result += " ";
    return result;
}
function toUpd(){
	/* 修改页面跳转 */
	$(".infoColorToUpd").click(function(){
		location.href = this.getAttribute("data-url") + "?" + this.getAttribute("data-params");
	});
}

function doDel(){
	/* 删除提示操作 */
	$(".infoColorDoDel").click(function(){
		 Swal({
	            title: '删除花色信息!!!',
	            type: 'warning',
	            showCancelButton: true,
	            confirmButtonText: '狠心删除',
	            cancelButtonText: '暂未决定',
	        }).then((rel) => {
	            if (rel.value) {
	            	location.href = this.getAttribute("data-url") + "?" + this.getAttribute("data-params");
	            }
	        });
	});
}
function doDelAll(co_ids){
	 $.ajax({
         url: 'doDelAll',
         data: {co_ids:co_ids},
         method:'post',
         dataType: 'json'
     }).done((result) => {
    	 location.href="toList";
     });
	 /*.fail((xhr) => {
         Swal({
             type: 'error',
             title: '服务器正在维护!',
         })
     });*/
}
$(function () {
    $('#bn-search').click(function(){
    	//$("#myForm").attr("action","getPageList");
    	//$("#myForm").submit();
    	$('#table').bootstrapTable('refresh');
    });
});

自定义操作JS

/*部门信息填写校验提示*/
$(function () {
    $("button[type=submit]").click(function () {
        var flag = false;
        $("input").each(function () {
            if (this.value == "") {
                flag = true;
            }
        });
        if (flag) {
            Swal({
                type: 'warning',
                title: '花色信息填写不完整',
                animation: false,
                customClass: 'animated tada'
            });
            return false;
        }
        
    });
    /*花色信息填写校验提示*/
    $("#sub_mit").click(function(){
    	 if (myform.co_id.value == "" || myform.co_name.value == "") {
    	        Swal({
    	            type: 'warning',
    	            title: '花色信息填写不完整',
    	            animation: false,
    	            customClass: 'animated tada'
    	        })
    	        return false;
    	    }
    });
});


Controller

package com.johe.scgcxx.controller.info;

import java.util.HashMap;
import java.util.Map;

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 org.springframework.web.bind.annotation.ResponseBody;

import com.johe.scgcxx.dto.Info_Color;
import com.johe.scgcxx.service.info.InfoColorService;
//基础信息-花色号维护
@Controller
@RequestMapping("/info/color")
public class InfoColorController {
	@Autowired
	private InfoColorService infoColorService;
	
	@RequestMapping("/getPageList")
	@ResponseBody
	public Map getList(Info_Color infoColor) {
		System.out.println(infoColor.toString());
		return infoColorService.getInfoColorPageMap(infoColor);
	}
	
	@RequestMapping("/toList")
	public String toList() {
		return "info/color/InfoColor";
	}
	
	@RequestMapping("/toAdd")
	public String toAdd() {
		return "info/color/InfoColorAdd";
	}
	
	@RequestMapping("/doAdd")
	public String doAdd(Info_Color infoColor) {
		infoColorService.addInfoColor(infoColor);
		return "redirect:toList";
	}
	
	@RequestMapping("/toUpd")
	public String toUpd(Model model,String co_id) {
		com.johe.scgcxx.model.Info_Color infoColor = infoColorService.getInfoColorById(co_id);
		model.addAttribute("infoColor", infoColor);
		return "info/color/InfoColorUpd";
	}
	
	@RequestMapping("/doUpd")
	public String doUpd(Info_Color infoColor) {
		infoColorService.updInfoColor(infoColor);
		return "redirect:toList";
	}
	
	@RequestMapping("/doDel")
	public String doDel(String co_id) {
		infoColorService.delInfoColorById(co_id);
		return "redirect:toList";
	}
	
	@RequestMapping("/doDelAll")
	@ResponseBody
	public Map doDelAll(String co_ids) {
		infoColorService.delInfoColorByIds(co_ids);
		System.out.println(co_ids);
		Map map = new HashMap<>();
		map.put("result", "success");
		return map; 
	}
	
	
	
}

ServiceImpl

package com.johe.scgcxx.service.info.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.johe.scgcxx.dao.info.InfoColorDao;
import com.johe.scgcxx.dto.Info_Color;
import com.johe.scgcxx.service.info.InfoColorService;
import com.johe.scgcxx.util.PageExec;
import com.johe.scgcxx.util.Utils;
//基础信息-花色号维护
@Service
public class InfoColorServiceImpl implements InfoColorService {

	@Autowired
	private InfoColorDao infoColorDao;

	@Override
	public List getInfoColorList() {
		Info_Color infoColor = null;
		return infoColorDao.getInfoColorList(infoColor);
	}
	
	@Override
	public void addInfoColor(Info_Color infoColor) {
		infoColorDao.addInfoColor(infoColor);
	}

	@Override
	public Integer getInfoColorNum() {
		return infoColorDao.getInfoColorNum();
	}

	@Override
	public com.johe.scgcxx.model.Info_Color getInfoColorById(String co_id) {
		return infoColorDao.getInfoColorById(co_id);
	}

	@Override
	public void updInfoColor(Info_Color infoColor) {
		infoColorDao.updInfoColor(infoColor);
	}

	@Override
	public Map  getInfoColorPageMap(Info_Color infoColor) {
		return
		Utils.getBootstrapTablePage(new PageExec() {
			@Override
			public List getList() {
				return infoColorDao.getInfoColorList(infoColor);
			}
		}, infoColor);
	}

	@Override
	public void delInfoColorById(String co_id) {
		infoColorDao.delInfoColorById(co_id);
	}
	
	@Override
	public void delInfoColorByIds(String co_ids) {
		String[] co_idss = co_ids.split(",");
		infoColorDao.delInfoColorByIds(co_idss);
	}

}

Dao

package com.johe.scgcxx.dao.info;

import java.util.List;

import com.johe.scgcxx.dto.Info_Color;

//基础信息-花色号维护
public interface InfoColorDao {
	
	List getInfoColorList(Info_Color infoColor);
	
	void addInfoColor(Info_Color infoColor);

	Integer getInfoColorNum();

	com.johe.scgcxx.model.Info_Color getInfoColorById(String co_id);

	void updInfoColor(Info_Color infoColor);

	void delInfoColorById(String co_id);

	void delInfoColorByIds(String[] co_idss);

}

DaoMapper.xml





	

	

	
		insert into info_color
		values(#{co_id},#{co_name},#{co_remark})
	
	
	
		update info_color
		
			
				co_name = #{co_name},
			
			
				co_remark = #{co_remark},
			
		
		where co_id = #{co_id}
	
	
		delete from info_color where co_id=#{co_id}
	
	
		delete from info_color
		
			co_id in
			
				#{co_id}
			
		
	

PageHelper的分页设置

分页实体类

package com.johe.scgcxx.util;

public class PageParam {
	
	
	private int offset;
	private int limit;
	
	public int getOffset() {
		return offset;
	}
	public void setOffset(int offset) {
		this.offset = offset;
	}
	public int getLimit() {
		return limit;
	}
	public void setLimit(int limit) {
		this.limit = limit;
	}

}

分页工具类

package com.johe.scgcxx.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

public class Utils {
	
	
	public static  PageInfo getPageInfo(PageExec exec,PageParam param){
		
		PageHelper.startPage((param.getOffset()/param.getLimit())+1, param.getLimit());
		List list = exec.getList();
		PageInfo pageInfo = new PageInfo<>(list);
		return pageInfo;
	}
	
	public static Map getBootstrapTablePage(Long num,List list){
		Map map = new HashMap();
		map.put("total",num);
		map.put("rows",list);
		return map;
		
	}
	
	public static  Map getBootstrapTablePage(PageExec exec,PageParam param){
		
		PageHelper.startPage(param.getOffset()/param.getLimit()+1, param.getLimit());
		List list = exec.getList();
		PageInfo pageInfo = new PageInfo<>(list);
		
		
		return getBootstrapTablePage(pageInfo.getTotal(),pageInfo.getList());
		
		
	}
	

}


分页接口

package com.johe.scgcxx.util;

import java.util.List;

public interface PageExec {
	
	
	public List getList();

}

你可能感兴趣的:(基础Spring整合Maven)