基于javaweb+mysql的ssm农业信息管理系统(java+ssm+jsp+js+html+mysql)

基于javaweb+mysql的ssm农业信息管理系统(java+ssm+jsp+js+html+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SSM农业信息管理系统(java+ssm+jsp+js+html+mysql)

项目介绍

管理员角色包含以下功能: 管理员登陆,用户管理,新闻管理,留言列表查看等功能。 用户角色包含以下功能: 查看所有新闻,市场资讯查看,科技推广查看,致富经栏目查看,网站留言,用户注册登陆等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:HTML+CSS+JavaScript+jsp

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
*/

@GetMapping({"/blog/{blogId}", "/article/{blogId}"})

public String detail(HttpServletRequest request, @PathVariable("blogId") Long blogId, @RequestParam(value = "commentPage", required = false, defaultValue = "1") Integer commentPage) {

BlogDetailVO blogDetailVO = blogService.getBlogDetail(blogId);

if (blogDetailVO != null) {

request.setAttribute("blogDetailVO", blogDetailVO);

request.setAttribute("commentPageResult", commentService.getCommentPageByBlogIdAndPageNum(blogId, commentPage));

request.setAttribute("pageName", "详情");

request.setAttribute("configurations", configService.getAllConfigs());

return "blog/" + theme + "/detail";

/**

* 标签列表页

* @param request http请求

* @param tagName 标签名称


if (StringUtils.isEmpty(blogTitle)) {

return ResultGenerator.genFailResult("请输入文章标题");

if (blogTitle.trim().length() > 150) {

return ResultGenerator.genFailResult("标题过长");

if (StringUtils.isEmpty(blogTags)) {

return ResultGenerator.genFailResult("请输入文章标签");

if (blogTags.trim().length() > 150) {

return ResultGenerator.genFailResult("标签过长");

if (blogSummary.trim().length() > 375) {

return ResultGenerator.genFailResult("摘要过长");


/**

* 博客列表

* @param params 参数

* @return com.hbu.myblog.util.Result

*/

@GetMapping("/blogs/list")

@ResponseBody

public Result list(@RequestParam Map<String, Object> params) {

if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {

return ResultGenerator.genFailResult("参数异常!");

PageQueryUtil pageUtil = new PageQueryUtil(params);


public String detail(HttpServletRequest request, @PathVariable("blogId") Long blogId, @RequestParam(value = "commentPage", required = false, defaultValue = "1") Integer commentPage) {

BlogDetailVO blogDetailVO = blogService.getBlogDetail(blogId);

if (blogDetailVO != null) {

request.setAttribute("blogDetailVO", blogDetailVO);

request.setAttribute("commentPageResult", commentService.getCommentPageByBlogIdAndPageNum(blogId, commentPage));

request.setAttribute("pageName", "详情");

request.setAttribute("configurations", configService.getAllConfigs());

return "blog/" + theme + "/detail";

/**

* 标签列表页

* @param request http请求


管理员管理控制层:

@Controller

@RequestMapping("/admin")

public class AdminController {

@Resource

private AdminUserService adminUserService;

@Resource

private BlogService blogService;

@Resource

private CategoryService categoryService;

@Resource


request.setAttribute("hotTags", tagService.getBlogTagCountForIndex());

request.setAttribute("pageName", "首页");

request.setAttribute("configurations", configService.getAllConfigs());

return "blog/" + theme + "/index";

/**

* Categories页面(包括分类数据和标签数据)

* @param request http请求

* @return java.lang.String

*/

@GetMapping({"/categories"})

public String categories(HttpServletRequest request) {


* @return com.hbu.myblog.util.Result

*/

@PostMapping("/blogs/save")

@ResponseBody

public Result save(@RequestParam("blogTitle") String blogTitle,

@RequestParam(name = "blogSummary", required = false) String blogSummary,

@RequestParam("blogCategoryId") Integer blogCategoryId,

@RequestParam("blogTags") String blogTags,

@RequestParam("blogContent") String blogContent,

@RequestParam("blogStatus") Byte blogStatus,


@RequestParam("verifyCode") String verifyCode,

HttpSession session) {

if (StringUtils.isEmpty(verifyCode)) {

session.setAttribute("errorMsg", "验证码不能为空");

return "admin/login";

if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {

session.setAttribute("errorMsg", "用户名或密码不能为空");

return "admin/login";

String kaptchaCode = session.getAttribute("verifyCode") + "";

if (StringUtils.isEmpty(kaptchaCode) || !verifyCode.equals(kaptchaCode)) {

session.setAttribute("errorMsg", "验证码错误");

return "admin/login";


request.setAttribute("configurations", configService.getAllConfigs());

return "blog/" + theme + "/list";

/**

* 搜索列表页

* @param request http请求

* @param keyword 关键词

* @return java.lang.String

*/

@GetMapping({"/search/{keyword}"})

public String search(HttpServletRequest request, @PathVariable("keyword") String keyword) {

return search(request, keyword, 1);

request.setAttribute("path", "index");

request.setAttribute("categoryCount", categoryService.getTotalCategories());

request.setAttribute("blogCount", blogService.getTotalBlogs());

request.setAttribute("tagCount", tagService.getTotalTags());

request.setAttribute("commentCount", commentService.getTotalComments());

return "admin/index";

/**

* 登录界面

* @param userName   用户名

* @param password   密码

* @param verifyCode 验证码


request.setAttribute("newBlogs", blogService.getBlogListForIndexPage(1));

request.setAttribute("hotBlogs", blogService.getBlogListForIndexPage(0));

request.setAttribute("hotTags", tagService.getBlogTagCountForIndex());

request.setAttribute("pageName", "首页");

request.setAttribute("configurations", configService.getAllConfigs());

return "blog/" + theme + "/index";

/**

* Categories页面(包括分类数据和标签数据)

* @param request http请求

* @return java.lang.String


return ResultGenerator.genFailResult("验证码不能为空");

String kaptchaCode = session.getAttribute("verifyCode") + "";

if (StringUtils.isEmpty(kaptchaCode)) {

return ResultGenerator.genFailResult("非法请求");

if (!verifyCode.equals(kaptchaCode)) {

return ResultGenerator.genFailResult("验证码错误");

String ref = request.getHeader("Referer");

if (StringUtils.isEmpty(ref)) {

return ResultGenerator.genFailResult("非法请求");

if (null == blogId || blogId < 0) {


} else {

return ResultGenerator.genFailResult("删除失败");

管理员管理控制层:

@Controller

@RequestMapping("/admin")

public class AdminController {

@Resource

private AdminUserService adminUserService;

@Resource

private BlogService blogService;

@Resource

private CategoryService categoryService;


return "admin/profile";

/**

* 修改密码

* @param request          http请求

* @param originalPassword 原始密码

* @param newPassword      新密码

* @return java.lang.String

*/

@PostMapping("/profile/password")

@ResponseBody

public String passwordUpdate(HttpServletRequest request, @RequestParam("originalPassword") String originalPassword,

@RequestParam("newPassword") String newPassword) {


@PostMapping(value = "/login")

public String login(@RequestParam("userName") String userName,

@RequestParam("password") String password,

@RequestParam("verifyCode") String verifyCode,

HttpSession session) {

if (StringUtils.isEmpty(verifyCode)) {

session.setAttribute("errorMsg", "验证码不能为空");

return "admin/login";

if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {

session.setAttribute("errorMsg", "用户名或密码不能为空");

return "admin/login";


return ResultGenerator.genFailResult("请输入文章标签");

if (blogTags.trim().length() > 150) {

return ResultGenerator.genFailResult("标签过长");

if (blogSummary.trim().length() > 375) {

return ResultGenerator.genFailResult("摘要过长");

if (StringUtils.isEmpty(blogContent)) {

return ResultGenerator.genFailResult("请输入文章内容");

if (blogTags.trim().length() > 100000) {

return ResultGenerator.genFailResult("文章内容过长");

Blog blog = new Blog();

blog.setBlogTitle(blogTitle);

blog.setBlogSummary(blogSummary);

blog.setBlogCategoryId(blogCategoryId);

blog.setBlogCategoryId(blogCategoryId);

blog.setBlogTags(blogTags);

blog.setBlogContent(blogContent);

blog.setBlogStatus(blogStatus);

blog.setEnableComment(enableComment);

String updateBlogResult = blogService.updateBlog(blog);

if ("success".equals(updateBlogResult)) {

return ResultGenerator.genSuccessResult("修改成功");

} else {

return ResultGenerator.genFailResult(updateBlogResult);


* 修改密码

* @param request          http请求

* @param originalPassword 原始密码

* @param newPassword      新密码

* @return java.lang.String

*/

@PostMapping("/profile/password")

@ResponseBody

public String passwordUpdate(HttpServletRequest request, @RequestParam("originalPassword") String originalPassword,

@RequestParam("newPassword") String newPassword) {

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值