iframe调用后台方法通过response返回html代码
16lz
2021-01-22
直接上代码
前台:
<iframe id='medicalRecordHTML' frameborder='0' src='xxx' style='width:100%;height:100%;' ></iframe>
后台:
try {
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html; charset=utf-8");
OutputStream out = response.getOutputStream();
String outHtml=medicalRecordService.findOneMedicalRecord(dto);
String webRoot=ServletActionContext.getRequest().getContextPath();
Pattern p = Pattern.compile("html\\.css");
Matcher m = p.matcher(outHtml);
if(m.find()){
String temp = outHtml.substring(m.start(),m.end());
outHtml = outHtml.replaceAll(temp,"\\"+webRoot+"\\/css\\/html\\.css" );
}
out.write(outHtml.getBytes());
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
虽然运行后台会抛错误,但是不影响功能。
更多相关文章
- HTML高级标签之窗口分帧(前台界面演示)
- 仿wordpress管理后台设计的后台管理框架
- 提交一个表单(后台生成id),点击保存并一步后切换到下一个tab中,此t
- nohup:在后台运行PHP进程
- 前台 post方法提交却变成了 get 方法
- 没有AJAX的拖放文件上传,在前台同步?
- 与kubectl exec运行后台进程
- Python--day56(前后台数据交互、bootstrap)
- fedora(linux)创建系统服务 程序开机自启 后台运行