1、演示
2、查看xml代码
public void loadXmlByModelId(@PathVariable String modelId, HttpServletResponse response) {
try {
Model model = modelService.getModel(modelId);
byte[] b = modelService.getBpmnXML(model);
response.setHeader("Content-type", "text/xml;charset=UTF-8");
response.getOutputStream().write(b);
} catch (Exception e) {
LOGGER.error("ApiFlowableModelResource-loadXmlByModelId:" + e);
e.printStackTrace();
}
}
3、查看图片
public void loadPngByModelId(@PathVariable String modelId, HttpServletResponse response) {
Model model = modelService.getModel(modelId);
BpmnModel bpmnModel = modelService.getBpmnModel(model, new HashMap<>(), new HashMap<>());
InputStream is = flowProcessDiagramGenerator.generateDiagram(bpmnModel);
try {
response.setHeader("Content-Type", "image/png");
byte[] b = new byte[1024];
int len;
while ((len = is.read(b, 0, 1024)) != -1) {
response.getOutputStream().write(b, 0, len);
}
} catch (Exception e) {
LOGGER.error("ApiFlowableModelResource-loadPngByModelId:" + e);
e.printStackTrace();
}
}