开发者

RestEasy - different XML marshalling in different actions

Let's say I have a user class which has a login, full name and last login information. There is also Post which has author, date it was created and content. Class could look something like this (please ignore public modifiers for now):

@XmlAccessorType(value = XmlAccessType.NONE)
public class User {

  @XmlElement
  public long id;

  @XmlElement
  public String login;

  public Date lastLogin;

  开发者_如何学C@XmlElement
  public String fullName;
}

@XmlAccessorType(value = XmlAccessType.NONE)
public class Post {
  @XmlElement
  public User author;

  @XmlElement
  public String content

  @XmlElement
  public Date dateCreated
}

In my rest action, when I return single post or posts collection in xml, every post contains author information with login and full name. But what should I do when I want to get a user (or collection), in xml format but complete, with all field values (in my example, including lastLogin field also)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜