作者主页:夜未央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项目:否;
技术栈
1. 后端:Spring Struts Hibernate
2. 前端:JSP+css+javascript+bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中hibernate.cfg.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ssh_tudisys 登录
运行截图
管理员角色
用户角色
相关代码
DangAnAction
package bysj.net.action;
import java.text.SimpleDateFormat;
import java.util.*;
import bysj.net.model.*;
import bysj.net.manager.ObjectManager;
import com.opensymphony.xwork2.*;
import bysj.net.util.PageModel;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
@SuppressWarnings({ "unchecked", "serial" })
public class DangAnAction extends ActionSupport {
private DangAn util;
private PageModel<DangAn> pageModel;
private List<User> listUser;
private List<FenLei> listFenLei;
private String errMsg;
private String field;
private String fieldValue;
private ObjectManager objectManager;
public String initUtil() throws Exception{
listUser = objectManager.getUtil("from User");
listFenLei = objectManager.getUtil("from FenLei");
util = null;
return "saveOrUpdate";
}
public String saveOrUpdateObject() throws Exception{
if("".equals(util.getS_0()) || null == util.getS_0()){
util.setS_0("BH"+ new SimpleDateFormat("hhmmsss").format(new Date()));
util.setS_10("已分配");
}
objectManager.saveOrUpdateObject(util);
util = null;
errMsg = null;
return getAllUtil();
}
public String deleteManyUtil() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
String ids[] = request.getParameterValues("id");
DangAn util = null;
for (String id : ids) {
util = new DangAn();
util.setId(Integer.parseInt(id));
objectManager.deleteObject(util);
}
util = null;
return getAllUtil();
} public String deleteUtil() throws Exception{
objectManager.deleteObject(util);
util = null;
errMsg = null;
return getAllUtil();
}
public String selectUtil() throws Exception{
listUser = objectManager.getUtil("from User");
listFenLei = objectManager.getUtil("from FenLei");
util = (DangAn) objectManager.getObject(new DangAn(), util.getId());
return "saveOrUpdate";
}
public String getAllUtil() throws Exception{
Map session = ActionContext.getContext().getSession();
String type = (String) session.get("type");
String name = (String) session.get("name");
int id = (Integer) session.get("id");
if (null == pageModel) {
pageModel = new PageModel<DangAn>();
}
if (0 == pageModel.getCurrentPageNo()) {
pageModel.setCurrentPageNo(1);
}
StringBuilder _sql = new StringBuilder();
_sql.append(" from DangAn where 1 = 1 ");
if (!"admin".equals(type)) {
// _sql.append(" and user.id = " + id);
}
if (null != field && field.trim().length() > 0) {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
_sql.append(" and " + field + " like '%" + fieldValue + "%'");
}
JiLu jiLu = new JiLu();
jiLu.setS_0(name);
jiLu.setS_1(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
objectManager.saveOrUpdateObject(jiLu);
pageModel = objectManager.getUtil(_sql.toString(), pageModel.getCurrentPageNo());
errMsg = null;
return "find";
}
public DangAn getUtil() {
return util;
}
public void setUtil(DangAn util) {
this.util = util;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
public ObjectManager getObjectManager() {
return objectManager;
}
public void setObjectManager(ObjectManager objectManager) {
this.objectManager = objectManager;
}
public PageModel<DangAn> getPageModel() {
return pageModel;
}
public void setPageModel(PageModel<DangAn> pageModel) {
this.pageModel = pageModel;
}
public List<User> getListUser() {
return listUser;
}
public void setListUser(List<User> listUser) {
this.listUser = listUser;
}
public List<FenLei> getListFenLei() {
return listFenLei;
}
public void setListFenLei(List<FenLei> listFenLei) {
this.listFenLei = listFenLei;
}
}
FenLeiAction
package bysj.net.action;
import java.util.*;
import bysj.net.model.FenLei;
import bysj.net.manager.*;
import com.opensymphony.xwork2.*;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import bysj.net.util.PageModel;
@SuppressWarnings({ "unchecked", "serial" })
public class FenLeiAction extends ActionSupport {
private String errMsg;
private String field;
private String fieldValue;
private ObjectManager objectManager;
private FenLei util;
private PageModel<FenLei> pageModel;
public String saveOrUpdateObject() throws Exception {
if (null != util && 0 == util.getId()) {
String sql = "from FenLei where s_0 = '" + util.getS_0() + "'";
List list = objectManager.getUtil(sql);
if (null != list && list.size() > 0) {
errMsg = "该信息已存在";
return "saveOrUpdate";
}
}
objectManager.saveOrUpdateObject(util);
util = null;
errMsg = null;
return getAllUtil();
}
public String deleteManyUtil() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
String ids[] = request.getParameterValues("id");
FenLei util = null;
for (String id : ids) {
util = new FenLei();
util.setId(Integer.parseInt(id));
objectManager.deleteObject(util);
}
util = null;
return getAllUtil();
} public String deleteUtil() throws Exception{
objectManager.deleteObject(util);
util = null;
return getAllUtil();
}
public String selectUtil() throws Exception{
util = (FenLei) objectManager.getObject(new FenLei(), util.getId());
errMsg = null;
return "saveOrUpdate";
}
public String getAllUtil() throws Exception{
if (null == pageModel) {
pageModel = new PageModel<FenLei>();
}
if (0 == pageModel.getCurrentPageNo()) {
pageModel.setCurrentPageNo(1);
}
StringBuilder _sql = new StringBuilder();
_sql.append(" from FenLei ");
if (null != field && field.trim().length() > 0) {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
_sql.append(" where " + field + " like '%" + fieldValue + "%'");
}
pageModel = objectManager.getUtil(_sql.toString(), pageModel.getCurrentPageNo());
errMsg = null;
return "find";
}
public FenLei getUtil() {
return util;
}
public void setUtil(FenLei util) {
this.util = util;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
public ObjectManager getObjectManager() {
return objectManager;
}
public void setObjectManager(ObjectManager objectManager) {
this.objectManager = objectManager;
}
public PageModel<FenLei> getPageModel() {
return pageModel;
}
public void setPageModel(PageModel<FenLei> pageModel) {
this.pageModel = pageModel;
}
}
JiLuAction
package bysj.net.action;
import java.util.*;
import bysj.net.model.*;
import bysj.net.manager.ObjectManager;
import com.opensymphony.xwork2.*;
import bysj.net.util.PageModel;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
@SuppressWarnings({ "unchecked", "serial" })
public class JiLuAction extends ActionSupport {
private JiLu util;
private PageModel<JiLu> pageModel;
private String errMsg;
private String field;
private String fieldValue;
private ObjectManager objectManager;
public String initUtil() throws Exception{
util = null;
return "saveOrUpdate";
}
public String saveOrUpdateObject() throws Exception{
objectManager.saveOrUpdateObject(util);
util = null;
errMsg = null;
return getAllUtil();
}
public String deleteManyUtil() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
String ids[] = request.getParameterValues("id");
JiLu util = null;
for (String id : ids) {
util = new JiLu();
util.setId(Integer.parseInt(id));
objectManager.deleteObject(util);
}
util = null;
return getAllUtil();
} public String deleteUtil() throws Exception{
objectManager.deleteObject(util);
util = null;
errMsg = null;
return getAllUtil();
}
public String selectUtil() throws Exception{
util = (JiLu) objectManager.getObject(new JiLu(), util.getId());
return "saveOrUpdate";
}
public String getAllUtil() throws Exception{
//Map session = ActionContext.getContext().getSession();
//String type = (String) session.get("type");
//int id = (Integer) session.get("id");
if (null == pageModel) {
pageModel = new PageModel<JiLu>();
}
if (0 == pageModel.getCurrentPageNo()) {
pageModel.setCurrentPageNo(1);
}
StringBuilder _sql = new StringBuilder();
_sql.append(" from JiLu where 1 = 1 ");
//if (!"admin".equals(type)) {
// _sql.append(" and user.id = " + id);
//}
if (null != field && field.trim().length() > 0) {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
_sql.append(" and " + field + " like '%" + fieldValue + "%'");
}
pageModel = objectManager.getUtil(_sql.toString(), pageModel.getCurrentPageNo());
errMsg = null;
return "find";
}
public JiLu getUtil() {
return util;
}
public void setUtil(JiLu util) {
this.util = util;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
public ObjectManager getObjectManager() {
return objectManager;
}
public void setObjectManager(ObjectManager objectManager) {
this.objectManager = objectManager;
}
public PageModel<JiLu> getPageModel() {
return pageModel;
}
public void setPageModel(PageModel<JiLu> pageModel) {
this.pageModel = pageModel;
}
}
LiuYanAction
package bysj.net.action;
import java.util.*;
import bysj.net.model.*;
import bysj.net.manager.ObjectManager;
import com.opensymphony.xwork2.*;
import bysj.net.util.PageModel;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
@SuppressWarnings({ "unchecked", "serial" })
public class LiuYanAction extends ActionSupport {
private LiuYan util;
private PageModel<LiuYan> pageModel;
private List<User> listUser;
private String errMsg;
private String field;
private String fieldValue;
private ObjectManager objectManager;
public String initUtil() throws Exception {
Map session = ActionContext.getContext().getSession();
String type = (String) session.get("type");
int id = (Integer) session.get("id");
if (!"admin".equals(type)) {
listUser = objectManager.getUtil("from User where id = " + id);
} else {
listUser = objectManager.getUtil("from User");
}
util = null;
return "saveOrUpdate";
}
public String saveOrUpdateObject() throws Exception {
objectManager.saveOrUpdateObject(util);
util = null;
errMsg = null;
return getAllUtil();
}
public String deleteManyUtil() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
String ids[] = request.getParameterValues("id");
LiuYan util = null;
for (String id : ids) {
util = new LiuYan();
util.setId(Integer.parseInt(id));
objectManager.deleteObject(util);
}
util = null;
return getAllUtil();
}
public String deleteUtil() throws Exception {
objectManager.deleteObject(util);
util = null;
errMsg = null;
return getAllUtil();
}
public String selectUtil() throws Exception {
Map session = ActionContext.getContext().getSession();
String type = (String) session.get("type");
int id = (Integer) session.get("id");
if (!"admin".equals(type)) {
listUser = objectManager.getUtil("from User where id = " + id);
} else {
listUser = objectManager.getUtil("from User");
}
util = (LiuYan) objectManager.getObject(new LiuYan(), util.getId());
return "saveOrUpdate";
}
public String getAllUtil() throws Exception {
// Map session = ActionContext.getContext().getSession();
// String type = (String) session.get("type");
// int id = (Integer) session.get("id");
if (null == pageModel) {
pageModel = new PageModel<LiuYan>();
}
if (0 == pageModel.getCurrentPageNo()) {
pageModel.setCurrentPageNo(1);
}
StringBuilder _sql = new StringBuilder();
_sql.append(" from LiuYan where 1 = 1 ");
// if (!"admin".equals(type)) {
// _sql.append(" and user.id = " + id);
// }
if (null != field && field.trim().length() > 0) {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
_sql.append(" and " + field + " like '%" + fieldValue + "%'");
}
pageModel = objectManager.getUtil(_sql.toString(),
pageModel.getCurrentPageNo());
errMsg = null;
return "find";
}
public LiuYan getUtil() {
return util;
}
public void setUtil(LiuYan util) {
this.util = util;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getFieldValue() {
return fieldValue;
}
public void setFieldValue(String fieldValue) {
this.fieldValue = fieldValue;
}
public ObjectManager getObjectManager() {
return objectManager;
}
public void setObjectManager(ObjectManager objectManager) {
this.objectManager = objectManager;
}
public PageModel<LiuYan> getPageModel() {
return pageModel;
}
public void setPageModel(PageModel<LiuYan> pageModel) {
this.pageModel = pageModel;
}
public List<User> getListUser() {
return listUser;
}
public void setListUser(List<User> listUser) {
this.listUser = listUser;
}
}
如果也想学习本系统,下面领取。关注并回复:114ssh