赞
踩
作者主页:夜未央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,前端代码中已写死,否则会报错;
- public class AdminWebAction extends ActionSupport {
-
- /**
- * Service层实例
- */
- private AdminService adminService;
-
- /**
- * 日志
- */
- private Logger log = Logger.getLogger(this.getClass());
-
- private Admin admin = new Admin();
-
- private Long id;
-
- @SuppressWarnings("unchecked")
- public String queryAdmin() {
- log.debug("queryAdmin" + "开始");
- HttpServletRequest request = ServletActionContext.getRequest();
- initSelect(request);
-
- int resultSize = 0;
- PageBean pageBean = null;
-
- // Loginuser user = (Loginuser) request.getSession().getAttribute("currentUser");
-
- resultSize = adminService.getCount(admin);
-
- pageBean = PageBean.getPageBean("admin",
- resultSize, request);
-
- pageBean.setPageSize(10);
- List list = adminService.findPageInfoAdmin(admin, pageBean);
- request.setAttribute("admin_list", list);
- log.debug("queryAdmin" + "结束");
- return Constants.LIST;
- }
-
-
-
-
- /**
- *
- * 进入增加界面
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String toAddAdmin() {
- log.debug("toAddAdmin" + "开始");
- HttpServletRequest request = ServletActionContext.getRequest();
- initSelect(request);
- Date date = new Date();
-
-
- log.debug("toAddAdmin" + "结束");
- return Constants.ADD;
- }
-
- /**
- *
- * 增加
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String addAdmin() {
- log.debug("addAdmin" + "开始");
- try {
- Admin admins=new Admin();
- admins.setName(admin.getName());
- List list = adminService.findPageInfoAdmin(admins, null);
- if (list != null && list.size() > 0) {
- HttpServletRequest request = ServletActionContext.getRequest();
- request.setAttribute("messageInfo", "用户名已经存在!");
- return toAddAdmin();
- }
-
- adminService.save(admin);
-
- admin = new Admin();
- } catch (Exception e) {
- e.printStackTrace();
- log.error("addAdmin failed" + admin.toString());
- }
- log.debug("addAdmin" + "结束");
- return queryAdmin();
- }
-
- /**
- *
- * 删除
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String delAdmin() {
- log.debug("delAdmin" + "开始");
- try {
- admin.setId(id);
- adminService.delete(admin);
- admin = new Admin();
- } catch (Exception e) {
- log.error("delAdmin failed" + admin.toString());
- }
- log.debug("delAdmin" + "结束");
- return queryAdmin();
- }
-
- /**
- *
- * 进入编辑界面
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String toEditAdmin() {
- log.debug("toEditAdmin" + "开始");
- HttpServletRequest request = ServletActionContext.getRequest();
- admin = adminService.getAdmin(id);
- initSelect(request);
- log.debug("toEditAdmin" + "结束");
- return Constants.EDIT;
- }
-
- /**
- *
- * 进入调整访问周期界面
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String tomodifyZQ() {
- log.debug("tomodifyZQ" + "开始");
- HttpServletRequest request = ServletActionContext.getRequest();
- admin = adminService.getAdmin(id);
- initSelect(request);
- log.debug("tomodifyZQ" + "结束");
- return "tomodifyZQ";
- }
-
- /**
- *
- * 查看信息
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String viewAdmin() {
- log.debug("viewAdmin" + "开始");
- admin = adminService.getAdmin(id);
- log.debug("viewAdmin" + "结束");
- return Constants.VIEW;
- }
-
- /**
- *
- * 编辑
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String editAdmin() {
- log.debug("editAdmin" + "开始");
- try {
-
-
- adminService.update(admin);
- admin = new Admin();
-
- } catch (Exception e) {
- log.error("editAdmin failed" + admin.toString());
- }
- log.debug("editAdmin" + "结束");
- return queryAdmin();
- }
-
-
- public String editMyAdmin() {
- log.debug("editMyAdmin" + "开始");
- try {
-
- HttpServletRequest request = ServletActionContext.getRequest();
-
- adminService.update(admin);
- request.getSession().setAttribute("currentUser", admin);
- admin = new Admin();
-
- request.setAttribute("messageInfo", "修改成功!");
-
- } catch (Exception e) {
- log.error("editMyAdmin failed" + admin.toString());
- }
- log.debug("editMyAdmin" + "结束");
- return "my";
- }
-
-
-
- /**
- * @param AdminService
- * the AdminService to set
- */
- public void setAdminService(AdminService adminService) {
- this.adminService = adminService;
- }
-
- public Admin getAdmin() {
- return admin;
- }
-
- public void setAdmin(Admin admin) {
- this.admin = admin;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public void initSelect(HttpServletRequest request) {
-
-
- }
-
- }
- public class UserWebAction extends ActionSupport {
-
- /**
- * Service层实例
- */
- private UserService userService;
-
- /**
- * 日志
- */
- private Logger log = Logger.getLogger(this.getClass());
-
- private User user = new User();
-
- private Long id;
-
- @SuppressWarnings("unchecked")
- public String queryUser() {
- log.debug("queryUser" + "开始");
- HttpServletRequest request = ServletActionContext.getRequest();
- initSelect(request);
-
- int resultSize = 0;
- PageBean pageBean = null;
-
- // Loginuser user = (Loginuser) request.getSession().getAttribute("currentUser");
-
- resultSize = userService.getCount(user);
- pageBean = PageBean.getPageBean("user",
- resultSize, request);
- pageBean.setPageSize(10);
- List list = userService.findPageInfoUser(user, pageBean);
- request.setAttribute("user_list", list);
- log.debug("queryUser" + "结束");
- return Constants.LIST;
- }
-
- /**
- *
- * 进入增加界面
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String toAddUser() {
- log.debug("toAddUser" + "开始");
- HttpServletRequest request = ServletActionContext.getRequest();
- initSelect(request);
- Date date = new Date();
-
- log.debug("toAddUser" + "结束");
- return Constants.ADD;
- }
-
- /**
- *
- * 增加
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String addUser() {
- log.debug("addUser" + "开始");
- try {
- user.setAdddate(new Date().toLocaleString());
- userService.save(user);
-
- user = new User();
- } catch (Exception e) {
- e.printStackTrace();
- log.error("addUser failed" + user.toString());
- }
- log.debug("addUser" + "结束");
- return queryUser();
- }
-
- public String regUser() {
- log.debug("addUser" + "开始");
- try {
-
- user.setAdddate(new Date().toLocaleString());
- userService.save(user);
-
- user = new User();
- HttpServletRequest request = ServletActionContext.getRequest();
- request.setAttribute("messageInfo", "用户注册成功,请登录!");
- } catch (Exception e) {
- e.printStackTrace();
- log.error("addUser failed" + user.toString());
- }
- log.debug("addUser" + "结束");
- return "login";
- }
-
- /**
- *
- * 删除
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String delUser() {
- log.debug("delUser" + "开始");
- try {
- user.setId(id);
- userService.delete(user);
- user = new User();
- } catch (Exception e) {
- log.error("delUser failed" + user.toString());
- }
- log.debug("delUser" + "结束");
- return queryUser();
- }
-
- /**
- *
- * 进入编辑界面
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String toEditUser() {
- log.debug("toEditUser" + "开始");
- HttpServletRequest request = ServletActionContext.getRequest();
- user = userService.getUser(id);
- initSelect(request);
- log.debug("toEditUser" + "结束");
- return Constants.EDIT;
- }
-
- /**
- *
- * 进入调整访问周期界面
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String tomodifyZQ() {
- log.debug("tomodifyZQ" + "开始");
- HttpServletRequest request = ServletActionContext.getRequest();
- user = userService.getUser(id);
- initSelect(request);
- log.debug("tomodifyZQ" + "结束");
- return "tomodifyZQ";
- }
-
- /**
- *
- * 查看信息
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String viewUser() {
- log.debug("viewUser" + "开始");
- user = userService.getUser(id);
- log.debug("viewUser" + "结束");
- return Constants.VIEW;
- }
-
- /**
- *
- * 编辑
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public String editUser() {
- log.debug("editUser" + "开始");
- try {
- userService.update(user);
- HttpServletRequest request = ServletActionContext.getRequest();
- request.getSession().setAttribute("currentUser", user);
- user = new User();
- request.setAttribute("messageInfo", "更新成功!");
- } catch (Exception e) {
- log.error("editUser failed" + user.toString());
- }
- log.debug("editUser" + "结束");
- return "editsc";
- }
-
- /**
- * @param UserService
- * the UserService to set
- */
- public void setUserService(UserService userService) {
- this.userService = userService;
- }
-
- public User getUser() {
- return user;
- }
-
- public void setUser(User user) {
- this.user = user;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public void initSelect(HttpServletRequest request) {
- }
-
- }
如果也想学习本系统,下面领取。关注并回复:111ssh
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。