springMVC中从前台往后台传时间

原文链接:这里

0.前言

项目中前后台交互的时候很多地方需求传递时间。总结一下我遇到的一些方式。

1.时间戳形式

时间戳形式比较好请求,缺点是不能明显地看出时间点。

由于vue、angular等请求方式不完全一样,只列举请求的URL。

接口参考:

localhost:8080/app/?begin=1609459200000&end=1640966399999

后台controller可以参考下面的代码:

@ResponseBody
@RequestMapping(value = "/app", method = RequestMethod.GET)
public JSONArray app(@Param(value = "begin") Long begin,
@Param(value = "end") Long end){
try{
DateTime beginTimeT =new DateTime(beginTime); //
DateTime endTimeT =new DateTime(endTime); //转换成DateTime
}catch (Exception e){
e.printStackTrace();
}
return null;
}

posted on 2022-02-01 17:45  longkui  阅读(169)  评论(0编辑  收藏  举报

导航