• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Set a value for Xml Atribute in a response

 
Maya sekar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,

I am using Rest Web Services,
I use @XmlRootElement(name="") Annotation to change the xml tag value of the root element (i.e class name).
Say I wanted to use an annotation to change the attribute values, what annotation would I have to use,

SAy I have a bean

@XmlRootElement(name="Name")
Class Bean
{
@XmlElement(name="first")
String firstName;
@XmlElement(name="last")
String surname;

//getter and setters
}

only using @XmlElement or @XmlAttribute throws an error com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException

What annotation should I use?

Thank you
Have a nice day
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!