Hi all,
This could be a newbie question as I'm rather new to JAX-RS and Jersey,
but I'm struggling with the pluralization when using a @XmlRootElement
annotation.
I've rewritten the objects names to clarify my point. Could be that I've
made a typo, but you'll catch my drift as we go along. I have a dto
class definition like
@XmlRootElement(name = "myclass")
@XmlType(propOrder={"attr1", "attr2", "attr3"})
public class MyClassDto {
[etc..]
}
I'm using a dto transform to make clean objects as I'm not working with
the fullblown domain objects from the underlying business model. I also
don't want the annotations to bleed into my domain classes. Wrapping
from domain to dto classes in the following resource method fragment:
@GET
@Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML,
MediaType.APPLICATION_JSON })
public List<MyClassDto> getMyclasses() {
List<MyClassDto> list = new ArrayList<MyClassDto>();
for (MyClass o : MyClassDao.instance.getModel().values()) {
list.add(new MyclassDto(o));
}
return list;
}
In XML I have an output like
<myClassDtoes>
<myclass>
<attr1>value1</attr1>
<attr2>value2</attr2>
<attr3>value3</attr3>
</myclass>
<myclass>
<attr1>anothervalue1</attr1>
etc..
</myClassDtoes>
I would expect another name for the wrapper element, but my original
class name is being used and pluralized whereas the individual elements
use the @XmlRootElement provided.
Could someone help me out here? Is this standard behavior? Am I barking
up the wrong tree?
thanks for your time,
cheers,
Martijn
--
31.69 nHz = once a year