Java项目:117SpringBoot动漫论坛网站

博主主页:Java旅途

简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码

117SpringBoot动漫论坛网站

一、项目介绍

动漫论坛网站是由SpringBoot+Mybatis开发的,旅游网站分为前台和后台,前台为用户浏览,后台进行数据管理

后台功能如下:

  • 帖子管理
  • 分类管理
  • 标签管理

前台功能如下:

  • 帖子浏览
  • 帖子搜索
  • 分类查找
  • 标签查找
  • 帖子留言
  • 帖子回复

二、技术框架

  • 后端:SpringBoot,jpa
  • 前端:jquery

三、安装教程

  1. 用idea打开项目

  2. 在idea中配置jdk环境

  3. 配置maven环境并下载依赖

  4. 新建数据库,导入数据库文件

  5. 在application.properties文件中将数据库账号密码改成自己本地的

  6. 启动运行,管理员账号密码 admin/123456

四、项目截图

五、相关代码

IndexController

java 复制代码
package com.cartoonbbs.cartoonbbs.web;

import com.cartoonbbs.cartoonbbs.servive.ControllerService;
import com.cartoonbbs.cartoonbbs.servive.TagService;
import com.cartoonbbs.cartoonbbs.servive.TypeService;
import com.cartoonbbs.cartoonbbs.vo.CartoonQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
public class IndexController {
    @Autowired
    private ControllerService controllerService;
    @Autowired
    private TypeService typeService;
    @Autowired
    private TagService tagService;


    @GetMapping("/")
    public String index(@PageableDefault(size = 8,sort = {"updateTime"},direction = Sort.Direction.DESC) Pageable pageable,
                        Model model) {
        model.addAttribute("page",controllerService.listCartoon(pageable));
        model.addAttribute("types",typeService.listTypeTop(6));
        model.addAttribute("tags",tagService.listTagTop(10));
        model.addAttribute("recommendCartoon",controllerService.listRecommendCartoonTop(8));
        return "index";
    }
    @PostMapping("/search")
    public String search(@PageableDefault(size = 8,sort = {"updateTime"},direction = Sort.Direction.DESC) Pageable pageable,
                         @RequestParam String query, Model model){
        model.addAttribute("page",controllerService.listCartoon("%"+query+"%",pageable));
        model.addAttribute("query",query);
        return "search";

    }

    @GetMapping("/details/{id}")
    public String details(@PathVariable Long id, Model model) {
        //model.addAttribute("cartoon",controllerService.getCartoon(id));
        model.addAttribute("cartoon",controllerService.getAndConvert(id));
        return "details";
    }

}

LoginController

java 复制代码
package com.cartoonbbs.cartoonbbs.web.admin;

import com.cartoonbbs.cartoonbbs.dao.UserRepository;
import com.cartoonbbs.cartoonbbs.po.User;
import com.cartoonbbs.cartoonbbs.servive.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class LoginController {
    @Autowired
    private UserService userService;

    @GetMapping
    public  String loginPage(){
        return "admin/login";
    }

    @PostMapping("login")
    public String login(@RequestParam String username,
                        @RequestParam String password,
                        HttpSession session,
                        RedirectAttributes attributes
                      ){
            User user=userService.checkUse(username,password);
        if(user!=null){
            user.setPassword(null);
            session.setAttribute("user",user);
            return "admin/index";
        }else {
            attributes.addFlashAttribute("message","用户名和密码错误");
            return "redirect:/admin";
        }




    }
    @GetMapping("/logout")
    public  String logout(HttpSession session){
        session.removeAttribute("user");
        return "redirect:/admin";


    }
}

大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 104

相关推荐
松仔log40 分钟前
JetPack——Paging3+Room
android·java·zoom
biter down5 小时前
14:pytest-order 插件 顺序控制案例
开发语言·python·pytest
郝学胜-神的一滴5 小时前
Qt 高级开发 009: C++ Lambda 表达式
开发语言·c++·qt·软件构建
星栈独行6 小时前
我在 Rust 全栈项目里用 JWT 做无状态认证
开发语言·后端·rust·前端框架·开源·github·web
Lei活在当下6 小时前
先用起来,再理解,关于协程Coroutine应该知道的事
android·java·jvm
石山代码6 小时前
C++ 轻量级日志系统
开发语言·c++
Java爱好狂.6 小时前
Java程序员体系化学习路线(2026最新版)
java·后端·java面试·java架构师·java程序员·java八股文·java学习路线
tongluowan0077 小时前
以ReentrantLock为例解释AQS的工作流程
java·模板方法模式·aqs·reentrantlock
小技与小术7 小时前
玩转Flask
开发语言·python·flask
SilentSamsara7 小时前
Python 性能优化:tracemalloc、profiling 与 C 扩展加速
开发语言·python·青少年编程·性能优化