Document document = null;
document = DocumentHelper.parseText(msg);
// 格式化输出格式
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("utf-8");
StringWriter writer = new StringWriter();
// 格式化输出流
XMLWriter xmlWriter = new XMLWriter(writer, format);
// 将document写入到输出流
xmlWriter.write(document);
xmlWriter.close();
return writer.toString();
//xmp标签
<xmp id="msg" ></xmp>
<script th:inline="javascript">
function generateXML() {
$.ajax({
url: ctx + 'system/main/generate',
type: 'post',
async: false,
data: "",
success: function (res) {
//将生成的XML赋值到<xmp>标签下
document.getElementById("msg").innerHTML = res;
},
error:function(){
}
})
};
function clean() {
document.getElementById("msg").innerHTML = "";
};
</script>
1.html中加入xmp标签,JavaScript 触发ajax,
2.后台将string 类型的msg 转换成xml 格式 , 返回到html xmp标签中
3.定义按钮clean 情况msg内容
还没有评论,来说两句吧...