春季 3.1 JSON 日期格式
2022-09-01 10:24:08
我正在使用带注释的Spring 3.1 MVC代码(spring-mvc),当我通过@RequestBody发送日期对象时,日期显示为数字。这是我的控制器
@Controller
@RequestMapping("/test")
public class MyController {
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(Date.class,
new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),true));
}
@RequestMapping(value = "/getdate", method = RequestMethod.GET)
public @ResponseBody Date getDate(@RequestParam("dt") Date dt, Model model) {
// dt is properly constructed here..
return new Date();
}
}
当我传入日期时,我能够以格式接收日期。但是我的浏览器将日期显示为数字
1327682374011
如何使它以我为织布机注册的格式显示日期?我在一些论坛上看到我应该使用杰克逊映射器,但我不能改变现有的映射器吗?