[英]How to exclude fields within an object on a specific JAX - RS call?
I have the following Java
Person class: 我有以下Java
Person类:
public class Person {
private String id;
private String name = "";
private String score = "";
}
There are currently 3 REST
calls within my application, 2 of which will send all 3 fields within the Person
object 我的应用程序中当前有3个REST
调用,其中2个将发送Person
对象中的所有3个字段
However in my 3rd call I cannot send the "score" field within the object. 但是,在我的第3次通话中,我无法在对象内发送“得分”字段。
Is there a JAX-RS functionality to exclude this field for this one specific call? 是否有JAX-RS功能可排除此特定呼叫的此字段?
Current JAX-RS
Code: 当前的JAX-RS
代码:
if (person != null) {
return ResponseBuilder.anOKResponse().withEntity(person).build();
} else {
return ResponseBuilder.notFound().withEntity(PERSON_IS_NULL_ERROR).build();
}
If your app runs on weblogic, then your rest app is based on Jersey which uses moxy as the default message body reader and writer. 如果您的应用程序在weblogic上运行,则您的其余应用程序基于Jersey,后者使用moxy作为默认消息正文阅读器和编写器。 Please see this blog for detail info to solve your problems. 请参阅此博客以获取详细信息以解决您的问题。 http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.