zoukankan      html  css  js  c++  java
  • SpringMvc GET请求传递对象

    在controller层接收Get请求参数,最好还是用基本类型接收会比较好,即使是date类型的,也可以使用date类型去数据库查找。

    date类型不用去考虑用什么类型,如果数据库类型为datetime或date。用String类型就可以查询了。如下(注意符号)

     SELECT * FROM teacher WHERE create_time >= '2020/06/08 00:00:00'
        
    

    比如一个下载Excel的功能:

    
    				var searchDTO = {
    					Action: 'exportCollectionEx',
    					collectionId:this.searchForm.collectionId,
    					waybillNos:this.searchForm.waybillNos,
    					empNo:this.searchForm.empNo,
    					deptCode:this.searchForm.deptCode,
    					billDateStart:this.searchForm.collecteDate == undefined ? undefined:this.searchForm.collecteDate[0],
    					billDateEnd:this.searchForm.collecteDate == undefined ? undefined:this.searchForm.collecteDate[1]
    				}
    				this.$httpExt().get('/receivable/outstanding', searchDTO, {
    					headers: {
    						'Content-Type': 'application/octet-stream'
    					},
    					responseType: 'arraybuffer'
    				}).then(res => {
    					console.log(res.headers);
    					const [, fileName] = res.headers['content-disposition'].split('=');
    					const blob = new Blob([res.data])
    					const downloadElement = document.createElement('a');
    					const href = window.URL.createObjectURL(blob);
    					downloadElement.href = href;
    					downloadElement.download = fileName;
    					document.body.appendChild(downloadElement);
    					downloadElement.click();
    					document.body.removeChild(downloadElement);
    					window.URL.revokeObjectURL(href);
    				});
    

    controller

     @GetMapping(params = {"Action=exportCollectionEx"})
        public Response exportCollectionEx(CollectionExSearchDTO searchDTO,HttpServletResponse resp) {
    
        }
    

    DTO

    public class CollectionExSearchDTO {
    
        /**收款单号*/
        private String collectionId;
    
        /**
         * 运单号
         */
        private String waybillNo;
    
        /**
         * 员工号
         */
        private String empNo;
    
        /**
         * 网点
         */
        private String deptCode;
    
        /**
         * 收款开始日期
         */
        private String billDateStart;
    
        /**
         * 收款结束日期
         */
        private String billDateEnd;
    
        //set/get
    
  • 相关阅读:
    3D集合图元:最小边界框/包围盒(boundingbox)
    vs2012下 error4996
    将自己的类封装为lib的方法
    3D特征:关于HFM和HBB
    C++的Matlab接口
    BigDataMini导论
    vs2012编译boost_1_54_0
    RGB_D_开发征程(使用Kinect)
    **PCD数据获取:Kinect+OpenNI+PCL对接(代码)
    PCL:全程详解 VS2010+PCL配置
  • 原文地址:https://www.cnblogs.com/sean-zeng/p/13068815.html
Copyright © 2011-2022 走看看