xml文件下载报This XML file does not appear to have any style information associated with it. The document

xml文件下载报This XML file does not appear to have any style information associated with it. The document

It may be that the original file is missing the file declaration.
Normal xml file

<?xml version='1.0' encoding='UTF-8'?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
 
</definitions>

There is a problem like this

<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
 
</definitions>

No <?xml version='1.0' encoding='UTF-8'?>



2020-05-29 Supplement

Sometimes the XML file is downloaded through the interface, even if <?xml version='1.0' encoding='UTF-8'?> is added to the file, it still reports such an error. At this time, you can set the Header in the response

JAVA version

response.setHeader("Content-Disposition", "attachment; filename=" + name + ".bpmn20.xml");
response.setContentType("application/octet-stream");

go language version

//设置Content-Type
w.Header().Add("Content-Type", "application/octet-stream")
w.Header().Add("Content-Disposition", "attachment; filename=\""+name+"\".bpmn20.xml")

Guess you like

Origin blog.csdn.net/qq_34758074/article/details/92806783