作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
本项目为基于SSH的智能社区住户信息管理系统;
管理员角色包含以下功能:
管理员登录,小区信息管理,社区基本信息管理,居民管理,工作人员管理,房屋管理,停车位管理,居民收费管理,小区快递管理,用户管理,物业管理,一卡通管理,费用项目管理,报修管理,维修管理等功能。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
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 Struts Hibernate
2. 前端:JSP+css+javascript+jQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中hibernate.cfg.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
管理员账号/密码:admin/admin
- public class UserAction extends ActionSupport {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private List<UserBean> userList;// 用户信息集合
- private List<RoleBean> roleList;
- private UserBean model;
- private String id;
- private String tips;
- private PagerView pager = new PagerView();
- UserDao userDao;
-
- @Resource(name = "userDao")
- public void setUserDao(UserDao userDao) {
- this.userDao = userDao;
- }
-
- @Override
- public String execute() throws Exception {
- initData();
- return "success";
- }
-
- /**
- * 初始化数据
- */
- public void initData() {
-
- pager.setAllData(userDao.getDataNum());
-
- userList = userDao.getUserList(pager);
- roleList = userDao.getRoleList();
- }
-
- /**
- * 判断主键是否重复
- *
- * @throws IOException
- */
- public void exists() throws IOException {
- HttpServletResponse response = ServletActionContext.getResponse();
- PrintWriter out = response.getWriter();
-
- int result = userDao.exists(id) ? 1 : 0;
- out.print(result);
- out.flush();// 刷新
- out.close();// 关闭
- }
-
- /**
- * 物业费用信息添加
- *
- * @return 0[失败] >0[成功]
- */
- public String userAdd() {
- int result = 0;
- model.setUserPwd(EncryptHelper.md5(model.getUserPwd()));
- result = userDao.userAdd(model);
- if (result > 0) {
- tips = "添加成功!";
- } else {
- tips = "添加失败!";
- }
- initData();
- return "success";
- }
-
- /**
- * 删除单条信息
- *
- * @return true:删除成功;false:删除失败
- */
- public String delInfo() {
- int result = userDao.delInfo(id);
- if (result > 0) {
- setTips("删除成功!");
- } else {
- setTips("删除失败!");
- }
- initData();
- return "success";
- }
-
- /**
- * 删除所选中的记录
- *
- * @return
- */
- public String deleteUserLists() {
- HttpServletRequest request = ServletActionContext.getRequest();
- // 获取所选中的,名字叫delCost的复选框按钮的值
- String[] userList = request.getParameterValues("delUser");
- int result = 0;
- for (String item : userList) {
- result += userDao.delInfo(item);
- }
- this.tips = "成功删除了" + result + "条记录";
- initData();
- return "success";
- }
-
- /**
- * 根据费用编号获取要修改的物业费用信息
- *
- * @throws IOException
- */
- public void getUserModel() throws IOException {
- HttpServletResponse response = ServletActionContext.getResponse();
- response.setContentType("text/html");
- response.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();// 获取out
- out.print(JSONObject.fromObject(userDao.getEditInfo(id)));
- out.flush();
- out.close();
- }
-
- /**
- * 修改物业费用信息
- *
- * @return 受影响的行数
- */
- public String userEdit() {
- int result = 0;
-
- model.setUserPwd(EncryptHelper.md5(model.getUserPwd()));
- result = userDao.userUpdate(model);
- if (result > 0) {
- tips = "修改成功!";
- } else {
- tips = "修改失败!";
- }
- initData();
- return "success";
- }
-
- public List<UserBean> getUserList() {
- return userList;
- }
-
- public void setCostList(List<UserBean> userList) {
- this.userList = userList;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getTips() {
- return tips;
- }
-
- public void setTips(String tips) {
- this.tips = tips;
- }
-
- public PagerView getPager() {
- return pager;
- }
-
- public void setPager(PagerView pager) {
- this.pager = pager;
- }
-
- /**
- * @return the roleList
- */
- public List<RoleBean> getRoleList() {
- return roleList;
- }
-
- /**
- * @param roleList
- * the roleList to set
- */
- public void setRoleList(List<RoleBean> roleList) {
- this.roleList = roleList;
- }
-
- /**
- * @return the model
- */
- public UserBean getModel() {
- return model;
- }
-
- /**
- * @param model
- * the model to set
- */
- public void setModel(UserBean model) {
- this.model = model;
- }
-
- /**
- * @param userList
- * the userList to set
- */
- public void setUserList(List<UserBean> userList) {
- this.userList = userList;
- }
-
- }
- @SuppressWarnings("serial")
- public class LoginAction extends ActionSupport implements SessionAware {
- private String tips;
- private List<UserBean> userlist;
- private UserBean model;
- private Map<String, Object> session;
- private PagerView pager = new PagerView();
- private String account;
- private String userPwd;
- private String userName;
- private String identityCard;
-
- private UserBean userbean = new UserBean();
- UserDao userDao;
-
- LoginDao loginDao;
-
- @Resource(name = "loginDao")
- public void setLogindao(LoginDao loginDao) {
- this.loginDao = loginDao;
- }
-
- @Override
- public String execute() throws Exception {
-
- return super.execute();
- }
-
- // 管理员登陆验证
- public String LoginUser() {
- if (loginDao.userLogin(account, EncryptHelper.md5(userPwd))) {
- HttpServletRequest request = ServletActionContext.getRequest();
- UserBean userbean = loginDao.getUserLoginInfo(account);
- request.getSession().setAttribute("identity", userbean);
- tips = "登录成功";
- return "bbb";
- } else {
- tips = "账号或密码错误!";
- return "ccc";
- }
-
- }
-
- /**
- * 重置密码
- *
- */
- public String reSet() {
- HttpServletRequest request = ServletActionContext.getRequest();
- HttpSession session = request.getSession();
- String userPwd = request.getParameter("userPwd");
- userbean = (UserBean) session.getAttribute("identity");
- int result = 0;
- result = loginDao.reSet(userbean.getUserId(), userPwd);
- if (result > 0) {
- } else {
-
- }
- tips = "请使用新密码登录!";
- return "ddd";
-
- }
-
- /*
- * public void userUpdate(){ HttpServletRequest request =
- * ServletActionContext.getRequest(); HttpSession session =
- * request.getSession(); UserBean model = new UserBean(); String userPwd =
- * (String)session.getAttribute("userPwd"); model =
- * loginDao.getUserLoginInfo(account); session.putValue("", model);
- * model.setUserPwd(userPwd); model.setAccount(account.toString());
- * userDao.userUpdate(model); }
- */
-
- public String userUpdate() {
- HttpServletRequest request = ServletActionContext.getRequest();
- /*
- * HttpSession session = request.getSession(); UserBean model = new
- * UserBean(); String userPwd = (String)session.getAttribute("userPwd");
- */
- model = loginDao.getUserLoginInfo(account);
-
- session.put("AdminMain", model);
- model.setUserPwd(EncryptHelper.md5(userPwd));
- model.setAccount(account.toString());
- model.setUserName(userName);
- model.setIdentityCard(identityCard);
- loginDao.update(model);
- return "ddd";
- }
-
- /**
- * 登出
- */
- public String loginOut() {
- HttpServletRequest request = ServletActionContext.getRequest();
- request.getSession().removeAttribute("identity");// 将登录信息移除
- return "ccc";
- }
-
- public String getAccount() {
- return account;
- }
-
- public void setAccount(String account) {
- this.account = account;
- }
-
- public void setSession(Map<String, Object> session) {
- this.session = session;
- }
-
- /**
- * @return the pager
- */
- public PagerView getPager() {
- return pager;
- }
-
- /**
- * @param pager
- * the pager to set
- */
- public void setPager(PagerView pager) {
- this.pager = pager;
- }
-
- /**
- * @return the userPwd
- */
- public String getUserPwd() {
- return userPwd;
- }
-
- /**
- * @param userPwd
- * the userPwd to set
- */
- public void setUserPwd(String userPwd) {
- this.userPwd = userPwd;
- }
-
- /**
- * @return the loginbean
- */
- /*
- * public LoginBean getLoginbean() { return loginbean; }
- */
-
- /**
- * @param loginbean
- * the loginbean to set
- */
- /*
- * public void setLoginbean(LoginBean loginbean) { this.loginbean =
- * loginbean; }
- */
-
- /**
- * @param userlist
- * the userlist to set
- */
- public void setUserlist(List<UserBean> userlist) {
- this.userlist = userlist;
- }
-
- /**
- * @return the userbean
- */
- public UserBean getUserbean() {
- return userbean;
- }
-
- /**
- * @param userbean
- * the userbean to set
- */
- public void setUserbean(UserBean userbean) {
- this.userbean = userbean;
- }
-
- /**
- * @return the model
- */
- public UserBean getModel() {
- return model;
- }
-
- /**
- * @return the userlist
- */
- public List<UserBean> getUserlist() {
- return userlist;
- }
-
- /**
- * @param model
- * the model to set
- */
- public void setModel(UserBean model) {
- this.model = model;
- }
-
- /**
- * @return the tips
- */
- public String getTips() {
- return tips;
- }
-
- /**
- * @param tips
- * the tips to set
- */
- public void setTips(String tips) {
- this.tips = tips;
- }
-
- /**
- * @return the session
- */
- public Map<String, Object> getSession() {
- return session;
- }
-
- /**
- * @return the userName
- */
- public String getUserName() {
- return userName;
- }
-
- /**
- * @param userName
- * the userName to set
- */
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /**
- * @return the identityCard
- */
- public String getIdentityCard() {
- return identityCard;
- }
-
- /**
- * @param identityCard
- * the identityCard to set
- */
- public void setIdentityCard(String identityCard) {
- this.identityCard = identityCard;
- }
-
- }