【发布时间】:2021-07-02 13:58:26
【问题描述】:
我的项目中有以下代码:
@SessionScope
@RestController
public class cdaDisplayTool {
private final static Logger LOG = LoggerFactory.getLogger(cdaDisplayTool.class);
@PostMapping(path = "/display_XML", produces = "application/json; charset=utf-8")
protected JSONObject display_XML(@RequestBody ObjectNode model,HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String cda_base64 = null;
String htmlcda = null;
JSONObject results = new JSONObject();
if (model.has("cda_base64")) {
cda_base64 = model.get("cda_base64").asText();
byte[] decodedBytes = Base64.getDecoder().decode(cda_base64);
String decodedString = new String(decodedBytes);
String cda_xml = decodedString;
htmlcda = CdaXSLTransformer.getInstance().transform(cda_xml, "en-GB",
"/dispense");
}
LOG.info("cdahtml: "+ htmlcda);
results.accumulate("status", 200).accumulate("data", htmlcda);
return results;
}
}
当我记录htmlcda 参数时,我正确获取了 html 字符串。然而,作为对resultsJsonObject 的回应,我得到了 {"empty":false}。有什么帮助吗?
【问题讨论】:
-
@Nemanja,谢谢!您可以将其添加为接受它的响应。
-
@Zion 好的,我将其添加为响应 :)
标签: java json spring-boot