当前位置:   article > 正文

Java项目:SSH在线田园农场网站平台管理系统_java 农场

java 农场

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

管理员角色包含以下功能:
管理员登录,新闻管理,轮播图管理,产品类型管理,产品管理,荣誉管理,网址配备管理等功能。

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

环境需要

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版本;

6.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

技术栈

1. 后端:spring+structs+hibernate

2. 前端:JSP+bootstrap+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties与spring-mybatis.xml配置文件中的数据库配置改为自己的配置;
注:在spring-mybatis.xml没有将db.properties的数据同步过去的情况下修改;

4. 运行项目,输入localhost:8080/chaoshi 登录 注:tomcat中配置项目路径必须为/chaoshi,前端代码中已写死,否则会报错;

运行截图

 

 

 

 

 

相关代码 

管理端控制器

  1. public class AdminWebAction extends ActionSupport {
  2. /**
  3. * Service层实例
  4. */
  5. private AdminService adminService;
  6. /**
  7. * 日志
  8. */
  9. private Logger log = Logger.getLogger(this.getClass());
  10. private Admin admin = new Admin();
  11. private Long id;
  12. @SuppressWarnings("unchecked")
  13. public String queryAdmin() {
  14. log.debug("queryAdmin" + "开始");
  15. HttpServletRequest request = ServletActionContext.getRequest();
  16. initSelect(request);
  17. int resultSize = 0;
  18. PageBean pageBean = null;
  19. // Loginuser user = (Loginuser) request.getSession().getAttribute("currentUser");
  20. resultSize = adminService.getCount(admin);
  21. pageBean = PageBean.getPageBean("admin",
  22. resultSize, request);
  23. pageBean.setPageSize(10);
  24. List list = adminService.findPageInfoAdmin(admin, pageBean);
  25. request.setAttribute("admin_list", list);
  26. log.debug("queryAdmin" + "结束");
  27. return Constants.LIST;
  28. }
  29. /**
  30. *
  31. * 进入增加界面
  32. *
  33. * @param mapping
  34. * @param form
  35. * @param request
  36. * @param response
  37. * @return
  38. * @throws Exception
  39. */
  40. public String toAddAdmin() {
  41. log.debug("toAddAdmin" + "开始");
  42. HttpServletRequest request = ServletActionContext.getRequest();
  43. initSelect(request);
  44. Date date = new Date();
  45. log.debug("toAddAdmin" + "结束");
  46. return Constants.ADD;
  47. }
  48. /**
  49. *
  50. * 增加
  51. *
  52. * @param mapping
  53. * @param form
  54. * @param request
  55. * @param response
  56. * @return
  57. * @throws Exception
  58. */
  59. public String addAdmin() {
  60. log.debug("addAdmin" + "开始");
  61. try {
  62. Admin admins=new Admin();
  63. admins.setName(admin.getName());
  64. List list = adminService.findPageInfoAdmin(admins, null);
  65. if (list != null && list.size() > 0) {
  66. HttpServletRequest request = ServletActionContext.getRequest();
  67. request.setAttribute("messageInfo", "用户名已经存在!");
  68. return toAddAdmin();
  69. }
  70. adminService.save(admin);
  71. admin = new Admin();
  72. } catch (Exception e) {
  73. e.printStackTrace();
  74. log.error("addAdmin failed" + admin.toString());
  75. }
  76. log.debug("addAdmin" + "结束");
  77. return queryAdmin();
  78. }
  79. /**
  80. *
  81. * 删除
  82. *
  83. * @param mapping
  84. * @param form
  85. * @param request
  86. * @param response
  87. * @return
  88. * @throws Exception
  89. */
  90. public String delAdmin() {
  91. log.debug("delAdmin" + "开始");
  92. try {
  93. admin.setId(id);
  94. adminService.delete(admin);
  95. admin = new Admin();
  96. } catch (Exception e) {
  97. log.error("delAdmin failed" + admin.toString());
  98. }
  99. log.debug("delAdmin" + "结束");
  100. return queryAdmin();
  101. }
  102. /**
  103. *
  104. * 进入编辑界面
  105. *
  106. * @param mapping
  107. * @param form
  108. * @param request
  109. * @param response
  110. * @return
  111. * @throws Exception
  112. */
  113. public String toEditAdmin() {
  114. log.debug("toEditAdmin" + "开始");
  115. HttpServletRequest request = ServletActionContext.getRequest();
  116. admin = adminService.getAdmin(id);
  117. initSelect(request);
  118. log.debug("toEditAdmin" + "结束");
  119. return Constants.EDIT;
  120. }
  121. /**
  122. *
  123. * 进入调整访问周期界面
  124. *
  125. * @param mapping
  126. * @param form
  127. * @param request
  128. * @param response
  129. * @return
  130. * @throws Exception
  131. */
  132. public String tomodifyZQ() {
  133. log.debug("tomodifyZQ" + "开始");
  134. HttpServletRequest request = ServletActionContext.getRequest();
  135. admin = adminService.getAdmin(id);
  136. initSelect(request);
  137. log.debug("tomodifyZQ" + "结束");
  138. return "tomodifyZQ";
  139. }
  140. /**
  141. *
  142. * 查看信息
  143. *
  144. * @param mapping
  145. * @param form
  146. * @param request
  147. * @param response
  148. * @return
  149. * @throws Exception
  150. */
  151. public String viewAdmin() {
  152. log.debug("viewAdmin" + "开始");
  153. admin = adminService.getAdmin(id);
  154. log.debug("viewAdmin" + "结束");
  155. return Constants.VIEW;
  156. }
  157. /**
  158. *
  159. * 编辑
  160. *
  161. * @param mapping
  162. * @param form
  163. * @param request
  164. * @param response
  165. * @return
  166. * @throws Exception
  167. */
  168. public String editAdmin() {
  169. log.debug("editAdmin" + "开始");
  170. try {
  171. adminService.update(admin);
  172. admin = new Admin();
  173. } catch (Exception e) {
  174. log.error("editAdmin failed" + admin.toString());
  175. }
  176. log.debug("editAdmin" + "结束");
  177. return queryAdmin();
  178. }
  179. public String editMyAdmin() {
  180. log.debug("editMyAdmin" + "开始");
  181. try {
  182. HttpServletRequest request = ServletActionContext.getRequest();
  183. adminService.update(admin);
  184. request.getSession().setAttribute("currentUser", admin);
  185. admin = new Admin();
  186. request.setAttribute("messageInfo", "修改成功!");
  187. } catch (Exception e) {
  188. log.error("editMyAdmin failed" + admin.toString());
  189. }
  190. log.debug("editMyAdmin" + "结束");
  191. return "my";
  192. }
  193. /**
  194. * @param AdminService
  195. * the AdminService to set
  196. */
  197. public void setAdminService(AdminService adminService) {
  198. this.adminService = adminService;
  199. }
  200. public Admin getAdmin() {
  201. return admin;
  202. }
  203. public void setAdmin(Admin admin) {
  204. this.admin = admin;
  205. }
  206. public Long getId() {
  207. return id;
  208. }
  209. public void setId(Long id) {
  210. this.id = id;
  211. }
  212. public void initSelect(HttpServletRequest request) {
  213. }
  214. }

用户管理控制器

  1. public class UserWebAction extends ActionSupport {
  2. /**
  3. * Service层实例
  4. */
  5. private UserService userService;
  6. /**
  7. * 日志
  8. */
  9. private Logger log = Logger.getLogger(this.getClass());
  10. private User user = new User();
  11. private Long id;
  12. @SuppressWarnings("unchecked")
  13. public String queryUser() {
  14. log.debug("queryUser" + "开始");
  15. HttpServletRequest request = ServletActionContext.getRequest();
  16. initSelect(request);
  17. int resultSize = 0;
  18. PageBean pageBean = null;
  19. // Loginuser user = (Loginuser) request.getSession().getAttribute("currentUser");
  20. resultSize = userService.getCount(user);
  21. pageBean = PageBean.getPageBean("user",
  22. resultSize, request);
  23. pageBean.setPageSize(10);
  24. List list = userService.findPageInfoUser(user, pageBean);
  25. request.setAttribute("user_list", list);
  26. log.debug("queryUser" + "结束");
  27. return Constants.LIST;
  28. }
  29. /**
  30. *
  31. * 进入增加界面
  32. *
  33. * @param mapping
  34. * @param form
  35. * @param request
  36. * @param response
  37. * @return
  38. * @throws Exception
  39. */
  40. public String toAddUser() {
  41. log.debug("toAddUser" + "开始");
  42. HttpServletRequest request = ServletActionContext.getRequest();
  43. initSelect(request);
  44. Date date = new Date();
  45. log.debug("toAddUser" + "结束");
  46. return Constants.ADD;
  47. }
  48. /**
  49. *
  50. * 增加
  51. *
  52. * @param mapping
  53. * @param form
  54. * @param request
  55. * @param response
  56. * @return
  57. * @throws Exception
  58. */
  59. public String addUser() {
  60. log.debug("addUser" + "开始");
  61. try {
  62. user.setAdddate(new Date().toLocaleString());
  63. userService.save(user);
  64. user = new User();
  65. } catch (Exception e) {
  66. e.printStackTrace();
  67. log.error("addUser failed" + user.toString());
  68. }
  69. log.debug("addUser" + "结束");
  70. return queryUser();
  71. }
  72. public String regUser() {
  73. log.debug("addUser" + "开始");
  74. try {
  75. user.setAdddate(new Date().toLocaleString());
  76. userService.save(user);
  77. user = new User();
  78. HttpServletRequest request = ServletActionContext.getRequest();
  79. request.setAttribute("messageInfo", "用户注册成功,请登录!");
  80. } catch (Exception e) {
  81. e.printStackTrace();
  82. log.error("addUser failed" + user.toString());
  83. }
  84. log.debug("addUser" + "结束");
  85. return "login";
  86. }
  87. /**
  88. *
  89. * 删除
  90. *
  91. * @param mapping
  92. * @param form
  93. * @param request
  94. * @param response
  95. * @return
  96. * @throws Exception
  97. */
  98. public String delUser() {
  99. log.debug("delUser" + "开始");
  100. try {
  101. user.setId(id);
  102. userService.delete(user);
  103. user = new User();
  104. } catch (Exception e) {
  105. log.error("delUser failed" + user.toString());
  106. }
  107. log.debug("delUser" + "结束");
  108. return queryUser();
  109. }
  110. /**
  111. *
  112. * 进入编辑界面
  113. *
  114. * @param mapping
  115. * @param form
  116. * @param request
  117. * @param response
  118. * @return
  119. * @throws Exception
  120. */
  121. public String toEditUser() {
  122. log.debug("toEditUser" + "开始");
  123. HttpServletRequest request = ServletActionContext.getRequest();
  124. user = userService.getUser(id);
  125. initSelect(request);
  126. log.debug("toEditUser" + "结束");
  127. return Constants.EDIT;
  128. }
  129. /**
  130. *
  131. * 进入调整访问周期界面
  132. *
  133. * @param mapping
  134. * @param form
  135. * @param request
  136. * @param response
  137. * @return
  138. * @throws Exception
  139. */
  140. public String tomodifyZQ() {
  141. log.debug("tomodifyZQ" + "开始");
  142. HttpServletRequest request = ServletActionContext.getRequest();
  143. user = userService.getUser(id);
  144. initSelect(request);
  145. log.debug("tomodifyZQ" + "结束");
  146. return "tomodifyZQ";
  147. }
  148. /**
  149. *
  150. * 查看信息
  151. *
  152. * @param mapping
  153. * @param form
  154. * @param request
  155. * @param response
  156. * @return
  157. * @throws Exception
  158. */
  159. public String viewUser() {
  160. log.debug("viewUser" + "开始");
  161. user = userService.getUser(id);
  162. log.debug("viewUser" + "结束");
  163. return Constants.VIEW;
  164. }
  165. /**
  166. *
  167. * 编辑
  168. *
  169. * @param mapping
  170. * @param form
  171. * @param request
  172. * @param response
  173. * @return
  174. * @throws Exception
  175. */
  176. public String editUser() {
  177. log.debug("editUser" + "开始");
  178. try {
  179. userService.update(user);
  180. HttpServletRequest request = ServletActionContext.getRequest();
  181. request.getSession().setAttribute("currentUser", user);
  182. user = new User();
  183. request.setAttribute("messageInfo", "更新成功!");
  184. } catch (Exception e) {
  185. log.error("editUser failed" + user.toString());
  186. }
  187. log.debug("editUser" + "结束");
  188. return "editsc";
  189. }
  190. /**
  191. * @param UserService
  192. * the UserService to set
  193. */
  194. public void setUserService(UserService userService) {
  195. this.userService = userService;
  196. }
  197. public User getUser() {
  198. return user;
  199. }
  200. public void setUser(User user) {
  201. this.user = user;
  202. }
  203. public Long getId() {
  204. return id;
  205. }
  206. public void setId(Long id) {
  207. this.id = id;
  208. }
  209. public void initSelect(HttpServletRequest request) {
  210. }
  211. }

如果也想学习本系统,下面领取。关注并回复:111ssh

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/363900
推荐阅读
相关标签
  

闽ICP备14008679号