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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM