Day207&208,java高级面试宝典

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注Java)
img

正文

};

},

methods: {

//根据课程id查询对应的课程章节和小结

getChapterVideoByCourseId(){

chapter.getChapterVideoByCourseId(this.courseId)

.then(resp=>{

this.chapterVideoList = resp.data.allChapterVideo

})

},

},

created() {

//获取路由里的id值

if(this.KaTeX parse error: Expected 'EOF', got '&' at position 14: route.params &̲& this.route.params.id){

this.courseId = this.¥route.params.id

}

//根据课程id查询对应的课程章节和小结

this.getChapterVideoByCourseId();

},

};

4、组件模版

    • {{ chapter.title }}

      添加课时

      编辑

      删除

      • {{ video.title }}

        • {{ video.title }}

          编辑

          删除


          课程修改功能

          ================================================================

          一、后端接口实现


          1、根据课程id查询课程基本信息

          • EduCourseController

          //根据课程id查询课程基本信息

          @GetMapping(“/getCourseInfoById/{courseId}”)

          public R getCourseInfoById(@PathVariable String courseId){

          CourseInfoForm courseInfoForm = eduCourseService.getCourseInfo(courseId);

          return R.ok().data(“courseInfoForm”,courseInfoForm);

          }

          • EduCourseService

          //根据课程id查询课程基本信息

          CourseInfoForm getCourseInfo(String courseId);

          • EduCourseServiceImpl

          //课程描述注入

          @Autowired

          private EduCourseDescriptionService eduCourseDescriptionService;

          @Override

          public CourseInfoForm getCourseInfo(String courseId) {

          //查询课程表

          EduCourse eduCourse = baseMapper.selectById(courseId);

          CourseInfoForm courseInfoForm = new CourseInfoForm();

          BeanUtils.copyProperties(eduCourse,courseInfoForm);

          //查询简介表

          EduCourseDescription courseDescription = eduCourseDescriptionService.getById(courseId);

          courseInfoForm.setDescription(courseDescription.getDescription());

          return courseInfoForm;

          }


          2、修改课程信息

          • EduCourseController

          //修改课程信息

          @PostMapping(“/updateCourseInfo”)

          public R updateCourseInfo(@RequestBody CourseInfoForm courseInfoForm){

          eduCourseService.updateCourseInfo(courseInfoForm);

          return R.ok();

          }

          • EduCourseService

          //修改课程信息

          void updateCourseInfo(CourseInfoForm courseInfoForm);

          • EduCourseServiceImpl

          @Override

          public void updateCourseInfo(CourseInfoForm courseInfoForm) {

          //1、修改课程表

          EduCourse eduCourse = new EduCourse();

          BeanUtils.copyProperties(courseInfoForm,eduCourse);

          int update = baseMapper.updateById(eduCourse);

          if (update <= 0){

          throw new AchangException(20001,“修改课程信息失败”);

          }

          //2、修改描述信息

          EduCourseDescription eduCourseDescription = new EduCourseDescription();

          eduCourseDescription.setDescription(courseInfoForm.getDescription());

          eduCourseDescription.setId(courseInfoForm.getId());

          eduCourseDescriptionService.updateById(eduCourseDescription);

          }


          二、前端实现


          • 定义api方法

          guli-admin\src\api\teacher\course.js

          //根据课程id 查询课程基本信息

          getCourseInfoById(courseId){

          return request({

          url:/eduservice/edu-course/getCourseInfoById/${courseId},

          method: ‘get’,

          })

          },

          //修改课程信息

          updateCourseInfo(courseInfoForm){

          return request({

          url:“/eduservice/edu-course/updateCourseInfo”,

          method: ‘post’,

          data: courseInfoForm,

          })

          }

          • 修改chapter页面跳转路径

          guli-admin\src\views\edu\course\chapter.vue

          //跳转到上一步

          previous() {

          this.$router.push({ path: “/course/info/”+this.courseId});

          },

          next() {

          //跳转到第三步

          this.$router.push({ path: “/course/publish/”+this.courseId});

          }

          • info页面 created()

          created() {

          //判断路径中是否有课程id

          if (this.KaTeX parse error: Expected 'EOF', got '&' at position 14: route.params &̲& this.route.params.id) {

          this.courseId = this.$route.params.id;

          //根据课程id 查询课程基本信息

          this.getCourseInfo()

          },

          }

          • info页面 methods

          methods: {

          //获取课程信息

          getCourseInfo() {

          course.getCourseInfoById(this.courseId).then((resp) => {

          this.courseInfo = resp.data.courseInfoForm

          })

          },

          }

          • info页面 data

          data() {

          return {

          courseId: “”,

          };

          }

          • 测试

          在这里插入图片描述

          • 上面问题,二级分类中的数据显示出现了问题

          created() {

          //判断路径中是否有课程id

          if (this.KaTeX parse error: Expected 'EOF', got '&' at position 14: route.params &̲& this.route.params.id) {

          this.courseId = this.$route.params.id;

          //根据课程id 查询课程基本信息

          this.getCourseInfo();

          } else {

          //初始化所有讲师

          this.getListTeacher();

          //初始化一级分类

          this.getOneSubject();

          }

          }

          //获取课程信息

          getCourseInfo() {

          course.getCourseInfoById(this.courseId).then((resp) => {

          this.courseInfo = resp.data.courseInfoForm;

          //查询所有分类,包含一级和二级所有

          subject.getSubjectList().then((resp) => {

          //获取所有一级分类

          this.subjectOneLists = resp.data.list;

          //把所有一级分类数组进行遍历

          for (var i = 0; i < this.subjectOneLists.length; i++) {

          //获取每个一级分类

          var oneSubject = this.subjectOneLists[i];

          //比较当前courseInfo里面的一级分类id和所有的一级分类id是否一样

          if (this.courseInfo.subjectParentId == oneSubject.id) {

          //获取一级分类中所有的二级分类

          this.subjectTwoLists = oneSubject.children;

          }

          }

          });

          //初始化所有讲师

          this.getListTeacher();

          });

          }

          • 出现一个bug,就是回显数据后,再单击添加课程,数据还在,按理应该是清空数据

          添加监听器,监听路由,如果路由变化,就将courseInfo的数据清空

          watch: {

          $route(to, from) {

          //路由变化方式,当路由发送变化,方法就执行

          console.log(“watch $route”);

          this.courseInfo={}

          },

          }

          • 实现修改功能

          guli-admin\src\views\edu\course\info.vue

          //添加课程

          saveCourse() {

          course.addCourseInfo(this.courseInfo).then((resp) => {

          this.$message({

          message: “添加课程信息成功”,

          type: “success”,

          });

          //跳转到第二步,并带着这个课程生成的id

          this.$router.push({ path: “/course/chapter/” + resp.data.courseId });

          });

          },

          //修改课程

          updateCourse() {

          course.updateCourseInfo(this.courseInfo).then((resp) => {

          this.$message({

          message: “修改课程信息成功”,

          type: “success”,

          });

          //跳转到第二步,并带着这个课程生成的id

          this.$router.push({ path: “/course/chapter/” + this.courseId });

          });

          },

          //判断是修改还是新增

          saveOrUpdate() {

          //判断courseInfo中是否有id值

          if (this.courseInfo.id) {

          //有id值,为修改

          this.updateCourse();

          } else {

          //没id值,为添加

          this.saveCourse();

          }

          }


          课程章节添加修改删除功能

          ======================================================================

          一、后端接口实现


          • controller

          //添加章节

          @PostMapping(“addChapter”)

          public R addChapter(@RequestBody EduChapter eduChapter){

          eduChapterService.save(eduChapter);

          return R.ok();

          }

          //根据章节id查询

          @GetMapping(“getChapter/{chapterId}”)

          public R getChapter(@PathVariable String chapterId){

          EduChapter eduChapter = eduChapterService.getById(chapterId);

          return R.ok().data(“chapter”,eduChapter);

          }

          //修改章节

          @PostMapping(“updateChapter”)

          public R updateChapter(@RequestBody EduChapter eduChapter){

          eduChapterService.updateById(eduChapter);

          return R.ok();

          }

          //删除章节

          @DeleteMapping(“deleteById/{chapterId}”)

          public R deleteById(@PathVariable String chapterId){

          boolean flag = eduChapterService.deleteChapter(chapterId);

          if (flag){

          return R.ok();

          }else {

          return R.error();

          }

          }

          • service

          boolean deleteChapter(String chapterId);

          • serviceImpl

          //删除章节的方法

          @Override

          public boolean deleteChapter(String chapterId) {

          //根据chapter章节id 查询查询小节表,如果查询有数据,则不删除

          QueryWrapper wrapper = new QueryWrapper<>();

          wrapper.eq(“chapter_id”,chapterId);

          int count = eduVideoService.count(wrapper);

          //判断

          if (count>0){

          //能查询出来小节,不进行删除

          throw new AchangException(20001,“还有小节数据,不能删除”);

          }else {

          //不能查询出小节,进行删除

          int delete = baseMapper.deleteById(chapterId);

          return delete>0;

          }

          }


          二、前端页面实现


          • 定义api

          //添加章节

          addChapter(chapter) {

          return request({

          url: /eduservice/edu-chapter/addChapter,

          method: post,

          data: chapter

          })

          },

          //根据id查询章节

          updateChapterById(chapterID) {

          return request({

          url: /eduservice/edu-chapter/getChapter/${chapterID},

          method: get,

          })

          },

          //修改章节

          updateChapter(chapter) {

          return request({

          url: /eduservice/edu-chapter/updateChapter,

          method: post,

          data: chapter

          })

          },

          //删除章节

          deleteById(chapterID) {

          return request({

          url: /eduservice/edu-chapter/deleteById/${chapterID},

          method: delete,

          })

          }

          • 引入api

          import chapter from “@/api/teacher/chapter.js”;

          • 【添加课程】前端实现

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RnDlKFNU-1614611373370)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301192930998.png)]

          methods: {

          //添加章节

          saveChapter() {

          //设置课程id到chapter对象中

          this.chapter.courseId = this.courseId

          chapter.addChapter(this.chapter).then((resp) => {

          //关闭弹框

          this.dialogChapterFormVisible = false;

          //提示信息

          this.$message({

          message: “添加章节成功”,

          type: “success”,

          });

          //刷新页面

          this.getChapterVideoByCourseId()

          });

          },

          saveOrUpdate() {

          this.saveChapter()

          }

          }

          • 设置com.achang.eduservice.entity.EduChapter的创建时间和更新时间自动增添

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cSQ1jeQ8-1614611373373)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301193058647.png)]

          • 测试新增章节功能是否优先

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-haSaK6wy-1614611373374)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301193140747.png)]

          • 设置弹出表单时,清空数据

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zEe86p2C-1614611373375)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301193809829.png)]

          //弹出添加章节表单

          openChapterDialog(){

          //清空之前的数据

          this.chapter={}

          //显示弹框

          this.dialogChapterFormVisible = true

          }

          • 【修改功能】实现

          //修改章节

          updateChapter() {

          //设置课程id到chapter对象中

          this.chapter.courseId = this.courseId;

          chapter.updateChapter(this.chapter).then((resp) => {

          //关闭弹框

          this.dialogChapterFormVisible = false;

          //提示信息

          this.$message({

          message: “修改章节成功”,

          type: “success”,

          });

          //刷新页面

          this.getChapterVideoByCourseId();

          });

          }

          saveOrUpdate() {

          if (this.chapter.id) {

          //修改章节

          this.updateChapter();

          } else {

          //新增章节

          this.saveChapter();

          }

          }


          • 【删除功能】实现

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TS94m8kw-1614611373377)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301201936160.png)]

          //删除章节

          removeById(chapterId) {

          this.$confirm(“此操作将永久删除章节信息, 是否继续?”, “提示”, {

          confirmButtonText: “确定”,

          cancelButtonText: “取消”,

          type: “warning”,

          }).then(() => {

          //点击确定,执行then方法

          chapter.deleteById(chapterId).then((resp) => {

          //删除成功

          //提示信息

          this.$message({

          type: “success”,

          message: “删除成功!”,

          });

          //刷新页面

          this.getChapterVideoByCourseId();

          });

          });

          }


          课程章节小节功能

          ==================================================================

          一、后端接口实现


          • com.achang.eduservice.controller.EduVideoController

          @RestController

          @RequestMapping(“/eduservice/edu-video”)

          @CrossOrigin //解决跨域问题

          public class EduVideoController {

          @Autowired

          private EduVideoService eduVideoService;

          //添加小节

          @PostMapping(“/addVideo”)

          public R addVideo(@RequestBody EduVideo eduVideo){

          eduVideoService.save(eduVideo);

          return R.ok();

          }

          //删除小节

          // TODO 后面这个方法需要完善,删除小节的时候,同时也要把视频删除

          @DeleteMapping(“/deleteVideo/{id}”)

          public R deleteVideo(@PathVariable String id){

          eduVideoService.removeById(id);

          return R.ok();

          }

          //修改小节

          @PostMapping(“/updateVideo”)

          public R updateVideo(@RequestBody EduVideo eduVideo){

          eduVideoService.updateById(eduVideo);

          return R.ok();

          }

          //根据小节id查询

          @GetMapping(“/getVideoById/{videoId}”)

          public R getVideoById(@PathVariable String videoId){

          EduVideo eduVideo = eduVideoService.getById(videoId);

          return R.ok().data(“video”,eduVideo);

          }

          }

          二、前端实现


          • 页面搭建

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-tE45zGri-1614611373379)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301210837755.png)]

          <el-input-number

          v-model=“video.sort”

          :min=“0”

          controls-

          position=“right”

          />

          免费

          默认

          <el-button @click=“dialogVideoFormVisible = false”>取 消

          <el-button

          :disabled=“saveVideoBtnDisabled”

          type=“primary”

          @click=“saveOrUpdateVideo(video.id)”

          确 定</el-button

          • api

          guli-admin\src\api\teacher\video.js

          import request from ‘@/utils/request’ //引入已经封装好的axios 和 拦截器

          export default {

          //添加小节

          addVideo(video) {

          return request({

          url: /eduservice/edu-video/addVideo,

          method: post,

          data: video

          })

          },

          //根据id查询小节

          getVideoById(videoId) {

          return request({

          url: /eduservice/edu-video/getVideoById/${videoId},

          method: get,

          })

          },

          //修改小节

          updateVideo(video) {

          return request({

          url: /eduservice/edu-video/updateVideo,

          method: post,

          data: video

          })

          },

          //删除小节

          deleteById(videoId) {

          return request({

          url: /eduservice/edu-video/deleteVideo/${videoId},

          method: delete,

          })

          },

          }

          • 引入api

          import video from “@/api/teacher/video.js”;

          • 方法定义

          //添加小节弹框的方法

          openEditVideo(chapterId) {

          //清空之前的数据

          this.video = {};

          //显示弹框

          this.dialogVideoFormVisible = true;

          //设置章节id

          this.video.chapterId = chapterId;

          },

          • 添加方法

          //添加小节

          addVideo() {

          //设置课程id

          this.video.courseId = this.courseId;

          video.addVideo(this.video).then((resp) => {

          //关闭弹框

          this.dialogVideoFormVisible = false;

          //提示信息

          this.$message({

          message: “添加小节成功”,

          type: “success”,

          });

          //刷新页面

          this.getChapterVideoByCourseId();

          });

          },

          • 给EduVideo,entity对象添加自动插入时间和修改时间

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PydDrQmx-1614611373381)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301211614154.png)]

          • 测试通过

          • 【删除小节】功能

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-MClVIf1z-1614611373382)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301213128067.png)]

          //删除小节

          removeVideo(videoId) {

          this.$confirm(“此操作将永久删除小节信息, 是否继续?”, “提示”, {

          confirmButtonText: “确定”,

          cancelButtonText: “取消”,

          type: “warning”,

          }).then(() => {

          //点击确定,执行then方法

          video.deleteById(videoId).then((resp) => {

          //删除成功

          //提示信息

          this.$message({

          type: “success”,

          message: “删除成功!”,

          });

          //刷新页面

          this.getChapterVideoByCourseId();

          });

          });

          },


          • 【小节修改】功能

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ypmselu5-1614611373384)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301214211583.png)]

          //修改小节表单回显

          getVideoById(videoId) {

          //弹出小节弹窗

          this.dialogVideoFormVisible = true;

          video.getVideoById(videoId).then((resp) => {

          this.video = resp.data.video;

          });

          },

          • 【小节修改】功能

          //小节修改

          updateVideorById(videoId) {

          //设置小节id到video对象中

          this.video.id = videoId;

          video.updateVideo(this.video).then((resp) => {

          //关闭弹框

          this.dialogVideoFormVisible = false;

          //提示信息

          this.$message({

          message: “修改小节成功”,

          type: “success”,

          });

          //刷新页面

          this.getChapterVideoByCourseId();

          });

          },

          • 测试

          [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2L2Oos8t-1614611373386)(../../../../../AppData/Roaming/Typora/typora-user-images/image-20210301220516228.png)]


          课程最终发布

          ================================================================

          一、后端实现


          • com.achang.eduservice.entity.vo.CoursePublishVo

          @Data

          public class CoursePublishVo implements Serializable {

          private static final long serialVersionUID = 1L;

          private String id;//课程id

          private String title; //课程名称

          private String cover; //封面

          private Integer lessonNum;//课时数

          private String subjectLevelOne;//一级分类

          private String subjectLevelTwo;//二级分类

          private String teacherName;//讲师名称

          private String price;//价格 ,只用于显示

          }

          • 数据访问层

          接口:EduCourseMapper

          public interface EduCourseMapper extends BaseMapper {

          public CoursePublishVo getPublishCourseInfo(String courseId);

          }

          实现:EduCourseMapper.xml

          <?xml version="1.0" encoding="UTF-8"?>

          SELECT

          ec.id,

          ec.title,

          ec.cover,

          ec.lesson_num AS lessonNum,

          ec.price,

          s1.title AS subjectLevelOne,

          s2.title AS subjectLevelTwo,

          t.name AS teacherName

          FROM

          edu_course ec

          LEFT JOIN edu_teacher t ON ec.id = t.id

          LEFT JOIN edu_subject s1 ON ec.subject_parent_id = s1.id

          LEFT JOIN edu_subject s2 ON ec.id = s2.id

          WHERE

          ec.id = #{id}

          • EduCourseMapper接口

          最后

          给大家送一个小福利

          附高清脑图,高清知识点讲解教程,以及一些面试真题及答案解析。送给需要的提升技术、准备面试跳槽、自身职业规划迷茫的朋友们。

          网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

          需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
          img

          一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
          oursePublishVo

          @Data

          public class CoursePublishVo implements Serializable {

          private static final long serialVersionUID = 1L;

          private String id;//课程id

          private String title; //课程名称

          private String cover; //封面

          private Integer lessonNum;//课时数

          private String subjectLevelOne;//一级分类

          private String subjectLevelTwo;//二级分类

          private String teacherName;//讲师名称

          private String price;//价格 ,只用于显示

          }

          • 数据访问层

          接口:EduCourseMapper

          public interface EduCourseMapper extends BaseMapper {

          public CoursePublishVo getPublishCourseInfo(String courseId);

          }

          实现:EduCourseMapper.xml

          <?xml version="1.0" encoding="UTF-8"?>

          SELECT

          ec.id,

          ec.title,

          ec.cover,

          ec.lesson_num AS lessonNum,

          ec.price,

          s1.title AS subjectLevelOne,

          s2.title AS subjectLevelTwo,

          t.name AS teacherName

          FROM

          edu_course ec

          LEFT JOIN edu_teacher t ON ec.id = t.id

          LEFT JOIN edu_subject s1 ON ec.subject_parent_id = s1.id

          LEFT JOIN edu_subject s2 ON ec.id = s2.id

          WHERE

          ec.id = #{id}

          • EduCourseMapper接口

          最后

          给大家送一个小福利

          [外链图片转存中…(img-SnyFRcre-1713470276210)]

          附高清脑图,高清知识点讲解教程,以及一些面试真题及答案解析。送给需要的提升技术、准备面试跳槽、自身职业规划迷茫的朋友们。

          [外链图片转存中…(img-UND424M8-1713470276211)]

          网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

          需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注Java)
          [外链图片转存中…(img-OfNh3ZNf-1713470276211)]

          一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

        • 16
          点赞
        • 24
          收藏
          觉得还不错? 一键收藏
        • 0
          评论
        在 SpringMVC 中,我们可以通过 ResponseBody 注解返回音频流,具体步骤如下: 1. 在 Controller 中定义一个返回类型为 ResponseEntity&lt;byte[]&gt; 的方法,该方法需要使用 @ResponseBody 注解标注。 2. 在方法中获取音频文件的字节数组,并将其放入 ResponseEntity 对象中返回。 3. 在 ResponseEntity 对象中设置 Content-Type、Content-Disposition 等响应头,以便浏览器正确解析音频流并进行播放。 示例代码如下: ```java @RequestMapping(&quot;/audio&quot;) @ResponseBody public ResponseEntity&lt;byte[]&gt; getAudio() throws IOException { // 读取音频文件字节数组 InputStream in = getClass().getResourceAsStream(&quot;/static/audio/sample.mp3&quot;); byte[] audioBytes = IOUtils.toByteArray(in); // 设置响应头 HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.parseMediaType(&quot;audio/mpeg&quot;)); headers.setContentDispositionFormData(&quot;attachment&quot;, &quot;sample.mp3&quot;); // 返回音频流 return new ResponseEntity&lt;&gt;(audioBytes, headers, HttpStatus.OK); } ``` 上述代码中,我们将音频文件 sample.mp3 放在了项目的 /static/audio 目录下。在方法中,我们使用 IOUtils.toByteArray() 方法将音频文件转换为字节数组,并将其放入 ResponseEntity 对象中返回。在设置响应头时,我们使用 MediaType.parseMediaType() 方法设置 Content-Type,使用 setContentDispositionFormData() 方法设置 Content-Disposition。最后,我们通过 new ResponseEntity&lt;&gt;(audioBytes, headers, HttpStatus.OK) 创建 ResponseEntity 对象并返回。

        “相关推荐”对你有帮助么?

        • 非常没帮助
        • 没帮助
        • 一般
        • 有帮助
        • 非常有帮助
        提交
        评论
        添加红包

        请填写红包祝福语或标题

        红包个数最小为10个

        红包金额最低5元

        当前余额3.43前往充值 >
        需支付:10.00
        成就一亿技术人!
        领取后你会自动成为博主和红包主的粉丝 规则
        hope_wisdom
        发出的红包
        实付
        使用余额支付
        点击重新获取
        扫码支付
        钱包余额 0

        抵扣说明:

        1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
        2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

        余额充值