一.首先先上效果图

二.实现:
参考:
https://blog.youkuaiyun.com/lanxuezaipiao/article/details/48193525
需求:通过课程ID和搜索内容查询到对应的数据
2.1.后端
/**
* 搜索博客
* 返回该课程的所有问题
* @return
*/
@GetMapping("/search")
@ResponseBody
public AjaxResult getSerachPostTitle(){
String courseID = ServletUtils.getParameter("courseID");
String title = ServletUtils.getParameter("title");
CoursePost coursePost=new CoursePost();
coursePost.setRoomId(Long.parseLong(courseID));//通过课程ID查询所有的博客
coursePost.setTitle(title);//通过标题查询所有的博客
List<CoursePost> coursePosts = postService.selectCoursePostList(coursePost);
AjaxResult ajax = new AjaxResult();
ajax.put("value", JSON.toJSONString(coursePosts));
ajax.put("code", 0);
return ajax;
}
2.2.前端
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>搜索博客

最低0.47元/天 解锁文章
2875

被折叠的 条评论
为什么被折叠?



