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
原文地址:https://www.cnblogs.com/sean-zeng/p/13068815.html