赞
踩
基于javaweb+mysql的springboot新闻发布系统(java+springboot+jsp+layui+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot新闻发布系统(java+springboot+jsp+layui+maven+mysql)
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
}*/ title=title.replace(search, "<font color='red'>"+search+"</font>"); System.out.println(title); x.setTitle(title); return x; }).collect(Collectors.toList()); request.setAttribute("list",newsList ); List<Category> categoryList = categoryDao.queryAll(); request.setAttribute("categoryList", categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList()));
public String show(){ List<Category> categoryList = categoryDao.queryAll(); categoryList=categoryList.stream().filter(x->x.getState().equals("1")).collect(Collectors.toList()); if(categoryList.size()>=5) request.setAttribute("list", categoryDao.queryAll()); request.setAttribute("msg","设置栏目显示失败,前台栏目最多显示5个"); return "listcategory"; }else { categoryDao.show(Integer.parseInt(request.getParameter("id"))); return "redirect:listforadmin"; @RequestMapping("/hidden") public String hidden(){ categoryDao.hidden(Integer.parseInt(request.getParameter("id")));
categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList())); return "searchnews"; 用户管理控制层: @Controller @RequestMapping("UsersServlet") public class UsersController { private UsersDao usersDao = new UsersDao(); @Autowired private HttpServletRequest request; @RequestMapping("/loginadmin") public String loginadmin() { String username = request.getParameter("username");
request.setAttribute("commentsList", commentsList); request.setAttribute("contentstr", content); request.setAttribute("categoryList", categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList())); return "detailnews"; @RequestMapping("/search") public String search(){ String search = request.getParameter("search"); request.setAttribute("searchStr", search); List<News> newsList = newsDao.queryAll(); newsList=newsList.stream().filter(x -> x.getTitle().contains(search)).collect(Collectors.toList());
@Autowired private HttpServletRequest request; private NewsDao newsDao = new NewsDao(); private CategoryDao categoryDao = new CategoryDao(); private CommentsDao commentsDao = new CommentsDao(); @RequestMapping("/publish") public String publish(){ String title = request.getParameter("title"); String content = request.getParameter("content"); String categoryid = request.getParameter("categoryid"); Users users = (Users) request.getSession().getAttribute("loginUsers"); Integer usersId = users.getId(); Integer deptid = users.getDeptid();
List<Users> list = usersDao.getUsers(); request.setAttribute("list", list); return "listusers"; 分类管理控制层: @Controller @RequestMapping("CategoryServlet") public class CategoryController { @Autowired private HttpServletRequest request; private CategoryDao categoryDao=new CategoryDao(); @RequestMapping("/listforadmin")
}else{ title=split[0]+"<font color='red'>"+search+"</font>"; }*/ title=title.replace(search, "<font color='red'>"+search+"</font>"); System.out.println(title); x.setTitle(title); return x; }).collect(Collectors.toList()); request.setAttribute("list",newsList ); List<Category> categoryList = categoryDao.queryAll(); request.setAttribute("categoryList",
return "login"; @RequestMapping("/userreg") public String userreg() { String username = request.getParameter("username"); String password = request.getParameter("password"); String account = request.getParameter("account"); String email = request.getParameter("email"); String password2 = request.getParameter("password2"); if (!password.equals(password2)) { request.setAttribute("error", "注册失败,密码与确认密码不一致!"); return "reg"; } else { boolean isSuccess = usersDao.isReg(account);
private HttpServletRequest request; private CategoryDao categoryDao=new CategoryDao(); @RequestMapping("/listforadmin") public String listforadmin(){ List<Category> categoryList = categoryDao.queryAll(); request.setAttribute("list", categoryList); return "listcategory"; @RequestMapping("/show") public String show(){ List<Category> categoryList = categoryDao.queryAll(); categoryList=categoryList.stream().filter(x->x.getState().equals("1")).collect(Collectors.toList());
public String loginadmin() { String username = request.getParameter("username"); String password = request.getParameter("password"); Users users = usersDao.login(username, password); if (users != null) { request.getSession().setAttribute("loginUsers", users); return "admin_index"; } else { request.setAttribute("msg", "登录失败,账号密码不匹配"); return "admin_login";
@Autowired private HttpServletRequest request; private NewsDao newsDao = new NewsDao(); private CategoryDao categoryDao = new CategoryDao(); private CommentsDao commentsDao = new CommentsDao(); @RequestMapping("/publish") public String publish(){ String title = request.getParameter("title"); String content = request.getParameter("content"); String categoryid = request.getParameter("categoryid"); Users users = (Users) request.getSession().getAttribute("loginUsers");
public String userlogin() { String userName = request.getParameter("username"); String password = request.getParameter("password"); String clientCheckcode = request.getParameter("validateCode"); String serverCheckcode = (String) request.getSession().getAttribute("checkcode"); if (clientCheckcode.equals(serverCheckcode)) { // 2. 去访问dao , 看看是否满足登录。 Users Users = usersDao.userlogin(userName, password); // 3. 针对dao的返回结果,做出响应 if (Users != null) { request.getSession().setAttribute("usersLogin", Users); CategoryDao categoryDao = new CategoryDao(); List<Category> categoryList = categoryDao.queryAll(); request.setAttribute("categoryList", categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList()));
@RequestMapping("/listforadmin") public String listforadmin() { List<Users> list = usersDao.getUsers(); request.setAttribute("list", list); return "listusers"; @RequestMapping("/del") public String del(Integer id) { usersDao.del(id); List<Users> list = usersDao.getUsers(); request.setAttribute("list", list);
request.setAttribute("categoryList", categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList())); return "detailnews"; @RequestMapping("/search") public String search(){ String search = request.getParameter("search"); request.setAttribute("searchStr", search); List<News> newsList = newsDao.queryAll(); newsList=newsList.stream().filter(x -> x.getTitle().contains(search)).collect(Collectors.toList()); newsList= newsList.stream().map(x->{ String title = x.getTitle();
@RequestMapping("/detail") public String detail(){ //测试 String id = request.getParameter("id"); if(id.contains(".jsp")) id= request.getParameter("id").replaceAll(".jsp",""); News news = newsDao.queryByid(Integer.parseInt(id)); news.setClicks(news.getClicks() + 1); newsDao.setClicksIncrement(news); NewsDetail detail = new NewsDetail(); detail.setNews(news);
public String show(){ List<Category> categoryList = categoryDao.queryAll(); categoryList=categoryList.stream().filter(x->x.getState().equals("1")).collect(Collectors.toList()); if(categoryList.size()>=5) request.setAttribute("list", categoryDao.queryAll()); request.setAttribute("msg","设置栏目显示失败,前台栏目最多显示5个"); return "listcategory"; }else { categoryDao.show(Integer.parseInt(request.getParameter("id"))); return "redirect:listforadmin"; @RequestMapping("/hidden") public String hidden(){
String categoryid = request.getParameter("categoryid"); News news = new News(); news.setCategoryid(Integer.parseInt(categoryid)); news.setContent(content); news.setPbdate(new Date()); news.setId(Integer.parseInt(request.getParameter("id"))); news.setTitle(title); newsDao.edit(news); return "redirect:listforadmin"; @RequestMapping("/del")
List<Category> categoryList = categoryDao.queryAll(); request.setAttribute("categoryList", categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList())); return "searchnews"; 用户管理控制层: @Controller @RequestMapping("UsersServlet") public class UsersController { private UsersDao usersDao = new UsersDao(); @Autowired private HttpServletRequest request; @RequestMapping("/loginadmin")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。