springMVC - get请求接收对象和个别参数

springMVC - get请求接收对象和个别参数

@RequestMapping(value = "/query", method = RequestMethod.GET)
@ResponseBody
 public ServiceData query(
 		@ModelAttribute UserVo userVo,
		@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
		@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize)
		throws Exception {
	// do something
	return null;
 }

Date 类型转成固定格式返回

1,在controller类中添加该方法

@InitBinder
protected void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
}

2,在实体类的日期类型字段上添加注解,否则返回的字段不起格式化的作用

/** 创建时间 */
 @JsonSerialize(using = DateSerializer.class)
 @JsonDeserialize(using = DateDeserializer.class)
 private Date creationDate;

你可能感兴趣的:(springMVC)