Struts2+JSON+jQuery实现异步交互数据时选择要序列化的属性(一注解方式)
package?test.json;
import?java.util.Date;
import?org.apache.struts2.json.annotations.JSON;
import?com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public?class?Users?extends?ActionSupport?
{
????private?int?id;
????private?String?userName;
????private?String?pwd;
????private?String?address;
????private?Date?birthday;
????public?int?getId()?
{
????????return?id;
????}
????public?void?setId(int?id)?
{
????????this.id?=?id;
????}
????@JSON(serialize=false)
????public?String?getUserName()?
{
????????return?userName;
????}
????
????public?void?setUserName(String?userName)?
{
????????this.userName?=?userName;
????}
????@JSON(name="mm")
????public?String?getPwd()?
{
????????return?pwd;
????}
????public?void?setPwd(String?pwd)?
{
????????this.pwd?=?pwd;
????}
????public?String?getAddress()?
{
????????return?address;
????}
????public?void?setAddress(String?address)?
{
????????this.address?=?address;
????}
????@JSON(format="yy-MM-dd")
????public?Date?getBirthday()?
{
????????return?birthday;
????}
????public?void?setBirthday(Date?birthday)?
{
????????this.birthday?=?birthday;
????}
????@Override
????public?String?execute()?throws?Exception?
{
????????
????????this.id?=?10000;
????????this.userName?=?"zhangsan";
????????this.pwd?=?"00000";
????????this.address?=?"xian";
????????this.birthday?=?new?Date();
????????
????????return?SUCCESS;
????}
}