Skip to content

Instantly share code, notes, and snippets.

@yanhua365
Last active December 28, 2015 09:29
Show Gist options
  • Save yanhua365/7479711 to your computer and use it in GitHub Desktop.
Save yanhua365/7479711 to your computer and use it in GitHub Desktop.
返回XML响应的Spring Boot CLI脚本。
package org.test
@Grab("spring-boot-starter-actuator")
@RestController
public class XmlResponseController {
@RequestMapping(value="/xml", method = RequestMethod.GET,produces = MediaType.APPLICATION_XML_VALUE)
public def hello() {
//实际应用的时候可以用MarkupBuilder来构造
'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<book>
<name>java in action.</name>
</book>
''';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment