【发布时间】:2013-03-16 09:44:33
【问题描述】:
如果我这样做:
@GET
@Path("/users")
@Produces("application/json")
public String users()
{
String users = null;
ArrayList<User> userList = new ArrayList<User>();
try {
userList = new UserManager().getUsers();
Gson gson = new Gson();
users = gson.toJson(userList);
} catch (Exception e) {
e.printStackTrace();
}
return users;
}
我的 GET 方法只是返回 JSON 格式的信息。
但我也希望它返回 XML 吗?类似@Produces({"application/xml", "application/json"})。
我该怎么做?
【问题讨论】: