@XmlRootElement public class Person { private String name; private int age; public static void main(String[] args) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(Person.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); Person person = new Person("John", 30); marshaller.marshal(person, System.out); } }


上一篇:
下一篇:
切换中文