1.前端请求
export function test(params) {
return request({
url: '/test',
method: 'get',
responseType: 'blob',
params: params
})
}
2.后端返回
@Override
public void test(HttpServletResponse response) {
try {
response.setContentType("application/msword;charset=utf-8");
response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode("test.docx", "utf-8"));
ClassLoader classLoader = getClass().getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream("templates/test.docx");
Map dataModel = new HashMap();
dataModel.put("name", "张三");
XWPFTemplate render = XWPFTemplate.compile(inputStream).render(dataModel);
ServletOutputStream outputStream = response.getOutputStream();
render.write(outputStream);
outputStream.flush();
} catch (Exception e) {
throw new ServiceException("下载异常");
}
}
3.前端处理响应结果
test(){
test().then(res=>{
const blob = new Blob([res]);
const downloadElement = document.createElement("a");
// 创建下载链接
const href = window.URL.createObjectURL(blob);
downloadElement.href = href;
// 下载后文件名
downloadElement.download = "test.docx";
document.body.appendChild(downloadElement);
// 点击下载
downloadElement.click();
document.body.removeChild(downloadElement);
window.URL.revokeObjectURL(href);
})
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
摘要:从图像提取人体姿态,用姿态信息控制生成具有相同姿态的新图像。 本文分享自华为云社区《Pose泰裤辣! 一键提取姿态生成新图像》,作者: Emma_Liu 。 人体姿态骨架生成图像 ControlNet-Human Pose in Stable Diffu…