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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律