git查看用户
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.budwk.app.web.controllers;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* @Author: 1V
|
||||
* @DateTime: 2020/12/3 8:50
|
||||
* @Description: TODO
|
||||
*/
|
||||
@At("/platform/basics")
|
||||
@IocBean
|
||||
@Ok("json")
|
||||
public class BasicsController {
|
||||
private static final Log log = Logs.get();
|
||||
|
||||
private final String TEMPLATE_PATH = "templates";
|
||||
|
||||
/**
|
||||
* 下载模板文件
|
||||
*
|
||||
* @param filePath
|
||||
* @param fileName
|
||||
* @param response
|
||||
*/
|
||||
@At
|
||||
public void downloadTemplate(String filePath, String fileName, HttpServletResponse response) throws IOException {
|
||||
try {
|
||||
response.setHeader("Content-Disposition", "attachment;filename="
|
||||
.concat(String.valueOf(URLEncoder.encode(fileName, "UTF-8"))));
|
||||
|
||||
if (filePath.startsWith("/")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
InputStream fin = Thread.currentThread().getContextClassLoader().getResourceAsStream(TEMPLATE_PATH + "/" + filePath);
|
||||
|
||||
IOUtils.copy(fin, response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user