mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-05 04:13:20 +08:00
修复文本文件下载乱码
This commit is contained in:
@@ -53,8 +53,8 @@ public abstract class GenericEntityService<E extends GenericEntity<PK>, PK>
|
||||
*/
|
||||
protected abstract IDGenerator<PK> getIDGenerator();
|
||||
|
||||
@Override
|
||||
public abstract CrudDao<E, PK> getDao();
|
||||
// @Override
|
||||
// public abstract CrudDao<E, PK> getDao();
|
||||
|
||||
@Override
|
||||
public int deleteByPk(PK pk) {
|
||||
|
||||
@@ -53,7 +53,7 @@ import static java.util.Optional.ofNullable;
|
||||
@RestController
|
||||
@RequestMapping("${hsweb.web.mappings.file:file}")
|
||||
@Authorize(permission = "file", description = "文件管理")
|
||||
@Api(value = "文件管理",tags = "文件管理-文件操作")
|
||||
@Api(value = "文件管理", tags = "文件管理-文件操作")
|
||||
@SuppressWarnings("all")
|
||||
public class FileController {
|
||||
|
||||
@@ -75,10 +75,6 @@ public class FileController {
|
||||
this.fileInfoService = fileInfoService;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Base64.encodeBase64String("hello".getBytes()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建并下载zip文件.仅支持POST请求
|
||||
*
|
||||
@@ -133,7 +129,8 @@ public class FileController {
|
||||
public void downloadTxt(@ApiParam("文件名") @PathVariable("name") String name,
|
||||
@ApiParam("文本内容") @RequestParam("text") String text,
|
||||
HttpServletResponse response) throws IOException {
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=utf-8");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(name, "utf-8"));
|
||||
response.getWriter().write(text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user