写一个针对 @GetMapping("exportstuinfo") public CommonResult<?> exportScore(HttpServletResponse response,String fileName) throws IOException { List<StuInfo> stuInfoList = adminMapper.selectStuInfo(); //设置响应头 fileName = new String(fileName.getBytes(),"ISO8859-1"); response.setHeader("Content-disposition", "attachment;filename=" + fileName); response.setContentType("application/octet-stream;charset=UTF-8"); response.addHeader("Pargam", "no-cache"); response.addHeader("Cache-Control", "no-cache"); EasyExcel.write(response.getOutputStream(), StuInfo.class).sheet("列表").doWrite(stuInfoList); return CommonResult.success("导出成功!"); }的apifox接口
时间: 2024-04-29 10:19:23 浏览: 27
您可以使用以下代码作为您的API接口:
```
/**
* 导出学生信息
*
* @param fileName 导出文件名
* @return CommonResult
*/
@GetMapping("exportstuinfo")
public CommonResult<?> exportStuInfo(String fileName, HttpServletResponse response) throws IOException {
List<StuInfo> stuInfoList = adminMapper.selectStuInfo();
//设置响应头
fileName = new String(fileName.getBytes(), "ISO8859-1");
response.setHeader("Content-disposition", "attachment;filename=" + fileName);
response.setContentType("application/octet-stream;charset=UTF-8");
response.addHeader("Pargam", "no-cache");
response.addHeader("Cache-Control", "no-cache");
EasyExcel.write(response.getOutputStream(), StuInfo.class).sheet("列表").doWrite(stuInfoList);
return CommonResult.success("导出成功!");
}
```
您可以将其复制并粘贴到您的项目中,然后在Apifox中创建一个GET请求,请求路径为您的API接口路径,例如:http://localhost:8080/exportstuinfo。然后在请求参数中添加fileName,值为您想要导出的文件名。最后,您可以在Apifox中测试您的API,以确保它正常工作。
相关推荐
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![html](https://img-home.csdnimg.cn/images/20210720083451.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)