博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring MVC基于注解来格式化数据
阅读量:7043 次
发布时间:2019-06-28

本文共 1125 字,大约阅读时间需要 3 分钟。

信息的转换,格式化,验证对于前端数据来说,

都是很有必要的。

这里实现一下格式化数据。

4a1c210df9162a34953c318c33a9f2edde8a1305

最重要的POJO定义如下:

user.java

package org.fkit.domain;import java.io.Serializable;import java.util.Date;import org.springframework.format.annotation.DateTimeFormat;import org.springframework.format.annotation.NumberFormat;import org.springframework.format.annotation.NumberFormat.Style;public class User implements Serializable {	/**	 * 	 */	private static final long serialVersionUID = 1L;	@DateTimeFormat(pattern="yyyy-MM-dd")	private Date birthday;		@NumberFormat(style=Style.NUMBER, pattern="#,###")	private int total;		@NumberFormat(style=Style.PERCENT)	private double discount;		@NumberFormat(style=Style.CURRENCY)	private double money;	public Date getBirthday() {		return birthday;	}	public void setBirthday(Date birthday) {		this.birthday = birthday;	}	public int getTotal() {		return total;	}	public void setTotal(int total) {		this.total = total;	}	public double getDiscount() {		return discount;	}	public void setDiscount(double discount) {		this.discount = discount;	}	public double getMoney() {		return money;	}	public void setMoney(double money) {		this.money = money;	}		}
1d7eec4050094d7de7e71f9f5ed211d04ef747f8

转载地址:http://yueal.baihongyu.com/

你可能感兴趣的文章
IIS权限应该怎么给?
查看>>
SpringMVC 拦截器和过滤器的区别&&Struts2拦截器和过滤器的区别
查看>>
Access:collating sort order SortOrder[2052(0)]
查看>>
Spark算子:RDD基本转换操作(1)–map、flagMap、distinct
查看>>
我的友情链接
查看>>
shell学习(二)变量
查看>>
Delphi随机数
查看>>
[置顶] webservice系列3---chain
查看>>
hibernate XML配置文件》cfg
查看>>
ExtJS2.0实用简明教程 - ExtJS的组件
查看>>
员工离职原因,只有两点最真实,其他都是扯淡!
查看>>
删除dataGridview中选中的一行或多行
查看>>
使用包ldap3进行Python的LDAP操作
查看>>
#4 Move Find into Model
查看>>
html5 canvas模拟的爆炸效果
查看>>
nodejs中几个excel模块的简单对比
查看>>
面向对象三大特征
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
Ansible学习01-常用模块
查看>>