@XmlType
/**
* bean对象转xml字符串
* @param obj bean对象
* @param clazz 要转的bean.Class
*
* @return object
*/
public static String beanToXml(Object obj, Class<?> clazz) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(clazz);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, "GBK");
StringWriter writer = new StringWriter();
marshaller.marshal(obj, writer);
return writer.toString();
}