1 2 3 4 5 6 7 | public Set<Object> getSingletons() { Set<Object> singletons = new HashSet<Object>(); singletons.add(new JsonGridProvider()); singletons.add(new JsonDojoTreeProvider()); return singletons; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | // Employee.java /** @XmlAccessorType Controls whether fields or Javabean properties are serialized by default XmlAccessType.FIELD: Every non static, non transient attribute in a JAXB-bound class will be automatically bound to XML, unless annotated by XmlTransient. Getter/setter pairs are bound to XML only when they are explicitly annotated by some of the JAXB annotations * */ @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Employee { @XmlElement private String id; @XmlElement private String name; @XmlElement private Boolean manager; @XmlElement private String sex; @XmlElement private String age; /** • @return the id */ public String getId() { return id; } /** • @param id the id to set */ public void setId(String id) { this.id = id; } /** • @return the name */ public String getName() { return name; } /** • @param name the name to set */ public void setName(String name) { this.name = name; } /** • @return the manager */ public Boolean getManager() { return manager; } /** • @param manager the manager to set */ public void setManager(Boolean manager) { this.manager = manager; } /** • @return the sex */ public String getSex() { return sex; } /** • @param sex the sex to set */ public void setSex(String sex) { this.sex = sex; } /** • @return the age */ public String getAge() { return age; } /** • @param age the age to set */ public void setAge(String age) { this.age = age; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class EmployeeView extends Employee { @XmlElementWrapper(name = "children") @XmlElement(name = "child") Set<EmployeeView> employeeSet ; public Set<EmployeeView> getChildrenRepresentation(){ return employeeSet; } public void setChildrenRepresentation(Set<EmployeeView> employeeSet){ this.employeeSet=employeeSet; } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |