I am new to Spring, and I need to pass from the spring controller an XML file to my JavaScript file. Can anyone detail me how I should do that? I have tried this on my controller, but the Response Body is no content.
@Api(value = "XML", description = "")
@RequestMapping("/XML/v1/setting")
public class XMLController{
@RequestMapping(method = RequestMethod.GET,
value = "/createFOO",
produces = "application/xml")
@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
public Document createFOO(){
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
Document doc1 = null;
try {
builder = factory.newDocumentBuilder();
doc1 = builder.parse(new FileInputStream("largeXmlGraph.xml"));
} catch (ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace();
}
return doc1;
}
}