spring - spring boot rest 下载 docx
问题描述
我正在尝试下载 docx 文件但编码出错
@GetMapping(value = ["/get-file"], produces = [MediaType.APPLICATION_OCTET_STREAM_VALUE])
@ResponseBody
@Throws(IOException::class)
fun getFile(): ByteArray {
val file = File("somePath\\data.docx")
val fis = FileInputStream(file)
return IOUtils.toByteArray(fis)
}
我能用这个做什么?
PKEi#P[Content_Types].xmlŖ�N�0E%�5。!����$��ֵ'���=���L�6B�i�b9��s��I���5�+��+��q>d8�v��=Mn �,�(��;(����r<�|T3��b����Q������)�V ����|3�'����!8
]��G�P����}^�.��*��@��N�,�L�s]�#2��杪��!52�G�������Ӿ��Gh�,����Ҕ\."z�l�C c@ K��NX*�;��6����P�L�T�dn�9��S��h��W
m<�j� |P�+!Fjbk�N�B�o��w��t�ㆭhVjR��jM���f�NNA�}�v���E��?�&��҈��bB �mB��m����i�`w~�&p;�@����""�zq��E���&��!�~z����^�v “L������7?|�OPK�<�。
解决方案
docx的媒体类型是:
application/vnd.openxmlformats-officedocument.wordprocessingml.document
推荐阅读
- progressive-web-apps - 我无法隐藏 TWA 上的浏览器栏
- javascript - 无法读取 JSON 属性。属性未定义
- elasticsearch - 弹性搜索多索引查询
- python - 来自数据框和剩余物的随机样本
- python - 在输出终端中剥离玩家的输入
- javascript - 使用 Javascript 清除复选框和单选按钮后需要单击两次
- python - 来自文本文件的两个字典,其中值是列和关键行数
- vue.js - 基于(可变)变量加载 Vue 组件
- windows - 无法使用 PostrgreSQL 将表导出到 CSV:Windows 上的权限被拒绝
- python - 如何在python中打印不带括号、逗号或引号的字符列表?