首页 前端知识 基于javaweb mysql的ssm流浪动物收养系统(java ssm jsp jquery mysql)

基于javaweb mysql的ssm流浪动物收养系统(java ssm jsp jquery mysql)

2024-06-08 09:06:12 前端知识 前端哥 342 357 我要收藏

基于javaweb+mysql的ssm流浪动物收养系统(java+ssm+jsp+jquery+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb的SSM流浪动物收养系统(java+ssm+jsp+jquery+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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

6.数据库:MySql 5.7/8.0等版本均可;

技术栈

  1. 后端:Spring+springmvc+mybatis

  2. 前端:JSP+css+javascript+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;

2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat

  1. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;

  2. 运行项目,在浏览器中输入http://localhost:8080/ 登录

用户账号/密码: user/123456

管理员账号/密码:admin/admin

	// 查看订购
	@RequestMapping("showOrders.action")
	public String showOrders(String number) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Orders orders = new Orders();
		orders.setUsersid(userid);
		List<Orders> ordersList = new ArrayList<Orders>();
		List<Orders> tempList = this.ordersService.getOrdersByCond(orders);
		int pageNumber = tempList.size();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Orders o = tempList.get(i);
			ordersList.add(o);
		}
		String html = "";
		StringBuffer buffer = new StringBuffer();
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
		List<Users> usersList = this.usersService.getAllUsers();
		this.getRequest().setAttribute("usersList", usersList);
		List<Jiancai> jiancaiList = this.jiancaiService.getAllJiancai();
		this.getRequest().setAttribute("jiancaiList", jiancaiList);
		return "admin/addtopic";
	}
	// 添加数据
	@RequestMapping("addTopic.action")
	public String addTopic(Topic topic) {
		this.topicService.insertTopic(topic);
		return "redirect:/topic/createTopic.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteTopic.action")
	public String deleteTopic(String id) {
		this.topicService.deleteTopic(id);
		return "redirect:/topic/getAllTopic.action";
	}

	// 批量删除数据
	@RequestMapping("deleteTopicByIds.action")
	public String deleteTopicByIds() {
		String[] ids = this.getRequest().getParameterValues("topicid");
		for (String topicid : ids) {
			this.topicService.deleteTopic(topicid);
		}
		return "redirect:/topic/getAllTopic.action";
	}

	// 更新数据
	@RequestMapping("updateTopic.action")
	public String updateTopic(Topic topic) {
		this.topicService.updateTopic(topic);
		return "redirect:/topic/getAllTopic.action";
	}
	// 显示全部数据
	@RequestMapping("getAllTopic.action")
	public String getAllTopic(String number) {
		List<Topic> topicList = this.topicService.getAllTopic();
		PageHelper.getPage(topicList, "topic", null, null, 10, number, this.getRequest(), null);

	// 退出登录
	@RequestMapping("exit.action")
	public String exit() {
		this.front();
		this.getSession().removeAttribute("userid");
		this.getSession().removeAttribute("username");
		this.getSession().removeAttribute("users");
		return "index";
	}

	// 准备修改密码
	@RequestMapping("prePwd.action")
	public String prePwd() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		return "users/editpwd";
	}

	// 修改密码
	@RequestMapping("editpwd.action")
	public String editpwd() {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		String password = this.getRequest().getParameter("password");
		String repassword = this.getRequest().getParameter("repassword");
		Users users = this.usersService.getUsersById(userid);
		if (password.equals(users.getPassword())) {
			users.setPassword(repassword);
			this.usersService.updateUsers(users);
		} else {
			this.getSession().setAttribute("message", "旧密码错误");
			return "redirect:/index/prePwd.action";
		}
		return "redirect:/index/prePwd.action";
	// 准备添加数据
	@RequestMapping("createAdmin.action")
	public String createAdmin() {
		return "admin/addadmin";
	}

	// 添加数据
	@RequestMapping("addAdmin.action")
	public String addAdmin(Admin admin) {
		admin.setAddtime(VeDate.getStringDateShort());
		this.adminService.insertAdmin(admin);
		return "redirect:/admin/createAdmin.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteAdmin.action")
	public String deleteAdmin(String id) {
		this.adminService.deleteAdmin(id);
		return "redirect:/admin/getAllAdmin.action";
	}

	// 批量删除数据
	@RequestMapping("deleteAdminByIds.action")
	public String deleteAdminByIds() {
		String[] ids = this.getRequest().getParameterValues("adminid");
		for (String adminid : ids) {
			this.adminService.deleteAdmin(adminid);
		}
		return "redirect:/admin/getAllAdmin.action";
	}

	// 更新数据
	@RequestMapping("updateAdmin.action")
	public String updateAdmin(Admin admin) {
		this.adminService.updateAdmin(admin);
		return "redirect:/admin/getAllAdmin.action";
	}

	// 显示全部数据
	@RequestMapping("getAllAdmin.action")
	public String getAllAdmin(String number) {
		List<Admin> adminList = this.adminService.getAllAdmin();

@Controller
@RequestMapping("/upload")
public class UploadAction {

	@RequestMapping(value = "/image.action")
	public String upload(@RequestParam(value = "image", required = false) MultipartFile file,
			HttpServletRequest request, ModelMap model) {
		String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/";
		String fileName = file.getOriginalFilename();
		int i = fileName.lastIndexOf(".");
		String name = String.valueOf(VeDate.getStringDatex());
		String type = fileName.substring(i + 1);
		fileName = name + "." + type;
		File targetFile = new File(path, fileName);
		if (!targetFile.exists()) {
			targetFile.mkdirs();
		}

		// 保存
		try {
			file.transferTo(targetFile);
		} catch (Exception e) {
			e.printStackTrace();
		}
		model.addAttribute("imageFileName", fileName);
		return "saveimage";
	}

	@RequestMapping(value = "/files.action")
	public String files(@RequestParam(value = "image", required = false) MultipartFile file, HttpServletRequest request,
			ModelMap model) {
		String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/";
		this.getRequest().setAttribute("articleList", articleList);
		return "users/article";
	}

	// 阅读公告
	@RequestMapping("read.action")
	public String read(String id) {
		this.front();
		Article article = this.articleService.getArticleById(id);
		article.setHits("" + (Integer.parseInt(article.getHits()) + 1));
		this.articleService.updateArticle(article);
		this.getRequest().setAttribute("article", article);
		return "users/read";
	}

	// 准备登录
	@RequestMapping("preLogin.action")
	public String prelogin() {
		this.front();
		return "users/login";
	}

	// 用户登录
	@RequestMapping("login.action")
	public String login() {
		this.front();
		String username = this.getRequest().getParameter("username");
		String password = this.getRequest().getParameter("password");
		Users u = new Users();
		u.setUsername(username);
		List<Users> usersList = this.usersService.getUsersByCond(u);
		if (usersList.size() == 0) {
			this.getSession().setAttribute("message", "用户名不存在");
			return "redirect:/index/preLogin.action";
		} else {
			Users users = usersList.get(0);
			if (password.equals(users.getPassword())) {
				this.getSession().setAttribute("userid", users.getUsersid());
				this.getSession().setAttribute("username", users.getUsername());
				this.getSession().setAttribute("users", users);
				return "redirect:/index/index.action";
			} else {
				this.getSession().setAttribute("message", "密码错误");
				return "redirect:/index/preLogin.action";
			}
		}
	}

	// 准备注册
	@RequestMapping("preReg.action")
	public String preReg() {
		this.front();
//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/topic" , produces = "text/plain;charset=utf-8")
public class TopicAction extends BaseAction {
	// 注入Service 由于标签的存在 所以不需要getter setter
	@Autowired
	@Resource
	private TopicService topicService;
	@Autowired
	@Resource
	private UsersService usersService;
	@Autowired
	@Resource
	private JiancaiService jiancaiService;

	// 准备添加数据
	@RequestMapping("createTopic.action")
	public String createTopic() {
		List<Users> usersList = this.usersService.getAllUsers();
		this.getRequest().setAttribute("usersList", usersList);
		List<Jiancai> jiancaiList = this.jiancaiService.getAllJiancai();
		this.getRequest().setAttribute("jiancaiList", jiancaiList);
		return "admin/addtopic";
	}
	// 添加数据
	@RequestMapping("addTopic.action")
	public String addTopic(Topic topic) {
		this.topicService.insertTopic(topic);
		return "redirect:/topic/createTopic.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteTopic.action")
	public String deleteTopic(String id) {
		this.topicService.deleteTopic(id);
		return "redirect:/topic/getAllTopic.action";
	}

	// 批量删除数据
	@RequestMapping("deleteTopicByIds.action")
	public String deleteTopicByIds() {
		String[] ids = this.getRequest().getParameterValues("topicid");
		for (String topicid : ids) {
		List<Users> usersList = this.usersService.getAllUsers();
		this.getRequest().setAttribute("usersList", usersList);
		List<Jiancai> jiancaiList = this.jiancaiService.getAllJiancai();
		this.getRequest().setAttribute("jiancaiList", jiancaiList);
		return "admin/addcart";
	}

	// 添加数据
	@RequestMapping("addCart.action")
	public String addCart(Cart cart) {
		this.cartService.insertCart(cart);
		return "redirect:/cart/createCart.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteCart.action")
	public String deleteCart(String id) {
		this.cartService.deleteCart(id);
		return "redirect:/cart/getAllCart.action";
	}

	// 批量删除数据
	@RequestMapping("deleteCartByIds.action")
	public String deleteCartByIds() {
		String[] ids = this.getRequest().getParameterValues("cartid");
		for (String cartid : ids) {
			this.cartService.deleteCart(cartid);
		}
		return "redirect:/cart/getAllCart.action";
	}

	// 更新数据
	@RequestMapping("updateCart.action")
	public String updateCart(Cart cart) {
		this.cartService.updateCart(cart);
		return "redirect:/cart/getAllCart.action";
	}

	// 显示全部数据
	@RequestMapping("getAllCart.action")
	public String getAllCart(String number) {
		List<Cart> cartList = this.cartService.getAllCart();
		PageHelper.getPage(cartList, "cart", null, null, 10, number, this.getRequest(), null);
		return "admin/listcart";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryCartByCond.action")
	public String queryCartByCond(String cond, String name, String number) {
		Cart cart = new Cart();
		if (cond != null) {
			buffer.append("下一页");
		} else {
			buffer.append("<a href=\"index/all.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
		}
		buffer.append("&nbsp;&nbsp;");
		if (maxPage <= (Integer.parseInt(number) + 1)) {
			buffer.append("尾页");
		} else {
			buffer.append("<a href=\"index/all.action?number=" + (maxPage - 1) + "\">尾页</a>");
		}
		html = buffer.toString();
		this.getRequest().setAttribute("html", html);
		this.getRequest().setAttribute("flimList", flimList);
		return "users/list";
	}

	// 查询演唱会
	@RequestMapping("query.action")
	public String query(String name) {
		this.front();
		Jiancai goods = new Jiancai();
		goods.setJiancainame(name);
		List<Jiancai> flimList = this.jiancaiService.getJiancaiByLike(goods);
		this.getRequest().setAttribute("flimList", flimList);
		return "users/list";
	}

	// 演唱会详情
	@RequestMapping("detail.action")
	public String detail(String id) {
		this.front();
		Jiancai goods = this.jiancaiService.getJiancaiById(id);
		goods.setHits("" + (Integer.parseInt(goods.getHits()) + 1));
		this.jiancaiService.updateJiancai(goods);
		this.getRequest().setAttribute("goods", goods);
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Topic topic = new Topic();
		topic.setJiancaiid(id);
		List<Topic> topicList = this.topicService.getTopicByCond(topic);
		this.getRequest().setAttribute("topicList", topicList);
		this.getRequest().setAttribute("tnum", topicList.size());
		return "users/detail";
	}

	@RequestMapping("addTopic.action")

//定义为控制器
@Controller
// 设置路径
@RequestMapping("/index")
public class IndexAction extends BaseAction {

	@Autowired
	@Resource
	private UsersService usersService;
	@Autowired
	@Resource
	private ArticleService articleService;
	@Autowired
	@Resource
	private CateService cateService;
	@Autowired
	@Resource
	private CityService cityService;
	@Autowired
	@Resource
	private PeihuoService peihuoService;
	@Autowired
	@Resource
	private JiancaiService jiancaiService;
	@Autowired
	@Resource
	private CartService cartService;
	@Autowired
	@Resource
	private OrdersService ordersService;
	@Autowired
	@Resource
	private DetailsService detailsService;
	@Autowired
			StringBuffer buffer = new StringBuffer();
			buffer.append("&nbsp;&nbsp;共为");
			buffer.append(maxPage);
			buffer.append("页&nbsp; 共有");
			buffer.append(pageNumber);
			buffer.append("条&nbsp; 当前为第");
			buffer.append((Integer.parseInt(number) + 1));
			buffer.append("页 &nbsp;");
			if ((Integer.parseInt(number) + 1) == 1) {
				buffer.append("首页");
			} else {
				buffer.append("<a href=\"index/recommend.action?number=0\">首页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if ((Integer.parseInt(number) + 1) == 1) {
				buffer.append("上一页");
			} else {
				buffer.append("<a href=\"index/recommend.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if (maxPage <= (Integer.parseInt(number) + 1)) {
				buffer.append("下一页");
			} else {
				buffer.append("<a href=\"index/recommend.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
			}
			buffer.append("&nbsp;&nbsp;");
			if (maxPage <= (Integer.parseInt(number) + 1)) {
				buffer.append("尾页");
			} else {
				buffer.append("<a href=\"index/recommend.action?number=" + (maxPage - 1) + "\">尾页</a>");
			}
			html = buffer.toString();
			this.getRequest().setAttribute("html", html);
			this.getRequest().setAttribute("flimList", flimList);
			return "users/list";
		}
		
		// 推荐产品
		@RequestMapping("hot.action")
		public String getHost(String number) {
			this.front();
			Jiancai goods = new Jiancai();
			goods.setRecommend("是");
			List<Jiancai> flimList = new ArrayList<Jiancai>();
			List<Jiancai> tempList = this.jiancaiService.getJiancaiByHot();
			int pageNumber = tempList.size();
			int maxPage = pageNumber;
			if (maxPage % 12 == 0) {
				maxPage = maxPage / 12;
			} else {
		return "admin/listcate";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryCateByCond.action")
	public String queryCateByCond(String cond, String name, String number) {
		Cate cate = new Cate();
		if (cond != null) {
			if ("catename".equals(cond)) {
				cate.setCatename(name);
			}
			if ("memo".equals(cond)) {
				cate.setMemo(name);
			}
			if ("addtime".equals(cond)) {
				cate.setAddtime(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.cateService.getCateByLike(cate), "cate", nameList, valueList, 10, number, this.getRequest(), "query");
		name = null;
		cond = null;
		return "admin/querycate";
	}

	// 按主键查询数据
	@RequestMapping("getCateById.action")
	public String getCateById(String id) {
		Cate cate = this.cateService.getCateById(id);
		this.getRequest().setAttribute("cate", cate);
		return "admin/editcate";
	}

	public CateService getCateService() {
		return cateService;
	}

	public void setCateService(CateService cateService) {
		this.cateService = cateService;
	}

}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryDetailsByCond.action")
	public String queryDetailsByCond(String cond, String name, String number) {
		Details details = new Details();
		if (cond != null) {
			if ("ordercode".equals(cond)) {
				details.setOrdercode(name);
			}
			if ("jiancaiid".equals(cond)) {
				details.setJiancaiid(name);
			}
			if ("num".equals(cond)) {
				details.setNum(name);
			}
			if ("price".equals(cond)) {
				details.setPrice(name);
			}
			if ("cityid".equals(cond)) {
				details.setCityid(name);
			}
			if ("peihuoid".equals(cond)) {
				details.setPeihuoid(name);
			}
			if ("viewdate".equals(cond)) {
				details.setViewdate(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.detailsService.getDetailsByLike(details), "details", nameList, valueList, 10, number, this.getRequest(),
				"query");
		name = null;
		cond = null;
		return "admin/querydetails";
	}

	// 按主键查询数据
	@RequestMapping("getDetailsById.action")
			if (password.equals(users.getPassword())) {
				this.getSession().setAttribute("userid", users.getUsersid());
				this.getSession().setAttribute("username", users.getUsername());
				this.getSession().setAttribute("users", users);
				return "redirect:/index/index.action";
			} else {
				this.getSession().setAttribute("message", "密码错误");
				return "redirect:/index/preLogin.action";
			}
		}
	}

	// 准备注册
	@RequestMapping("preReg.action")
	public String preReg() {
		this.front();
		return "users/register";
	}

	// 用户注册
	@RequestMapping("register.action")
	public String register(Users users) {
		this.front();
		Users u = new Users();
		u.setUsername(users.getUsername());
		List<Users> usersList = this.usersService.getUsersByCond(u);
		if (usersList.size() == 0) {
			users.setRegdate(VeDate.getStringDateShort());
			this.usersService.insertUsers(users);
		} else {
			this.getSession().setAttribute("message", "用户名已存在");
			return "redirect:/index/preReg.action";
		}

		return "redirect:/index/preLogin.action";
	}

	// 退出登录
	@RequestMapping("exit.action")
	public String exit() {
		this.front();
		this.getSession().removeAttribute("userid");
		this.getSession().removeAttribute("username");
		this.getSession().removeAttribute("users");
		return "index";
	}

		return "redirect:/index/showOrders.action";
	}

	// 查看订购
	@RequestMapping("showOrders.action")
	public String showOrders(String number) {
		this.front();
		if (this.getSession().getAttribute("userid") == null) {
			return "redirect:/index/preLogin.action";
		}
		String userid = (String) this.getSession().getAttribute("userid");
		Orders orders = new Orders();
		orders.setUsersid(userid);
		List<Orders> ordersList = new ArrayList<Orders>();
		List<Orders> tempList = this.ordersService.getOrdersByCond(orders);
		int pageNumber = tempList.size();
		int maxPage = pageNumber;
		if (maxPage % 12 == 0) {
			maxPage = maxPage / 12;
		} else {
			maxPage = maxPage / 12 + 1;
		}
		if (number == null) {
			number = "0";
		}
		int start = Integer.parseInt(number) * 12;
		int over = (Integer.parseInt(number) + 1) * 12;
		int count = pageNumber - over;
		if (count <= 0) {
			over = pageNumber;
		}
		for (int i = start; i < over; i++) {
			Orders o = tempList.get(i);
			ordersList.add(o);
		}
		String html = "";
		StringBuffer buffer = new StringBuffer();
		buffer.append("&nbsp;&nbsp;共为");
		buffer.append(maxPage);
		buffer.append("页&nbsp; 共有");
		buffer.append(pageNumber);
		buffer.append("条&nbsp; 当前为第");
		buffer.append((Integer.parseInt(number) + 1));
		buffer.append("页 &nbsp;");
@Resource
private OrdersService ordersService;
@Autowired
@Resource
private UsersService usersService;

// 准备添加数据
@RequestMapping("createOrders.action")
public String createOrders() {
List<Users> usersList = this.usersService.getAllUsers();
this.getRequest().setAttribute("usersList", usersList);
return "admin/addorders";
}
// 添加数据
@RequestMapping("addOrders.action")
public String addOrders(Orders orders) {
this.ordersService.insertOrders(orders);
return "redirect:/orders/createOrders.action";
}

// 通过主键删除数据
@RequestMapping("deleteOrders.action")
public String deleteOrders(String id) {
this.ordersService.deleteOrders(id);
return "redirect:/orders/getAllOrders.action";
}

// 批量删除数据
@RequestMapping("deleteOrdersByIds.action")
public String deleteOrdersByIds() {
String[] ids = this.getRequest().getParameterValues("ordersid");
for (String ordersid : ids) {
this.ordersService.deleteOrders(ordersid);
}
return "redirect:/orders/getAllOrders.action";
}

// 更新数据
@RequestMapping("updateOrders.action")
public String updateOrders(Orders orders) {
this.ordersService.updateOrders(orders);
return "redirect:/orders/getAllOrders.action";
}
// 显示全部数据
@RequestMapping("getAllOrders.action")
public String getAllOrders(String number) {
List<Orders> ordersList = this.ordersService.getAllOrders();
PageHelper.getPage(ordersList, "orders", null, null, 10, number, this.getRequest(), null);
return "admin/listorders";
}

// 按条件查询数据 (模糊查询)
@RequestMapping("queryOrdersByCond.action")
	public String getAllCity(String number) {
		List<City> cityList = this.cityService.getAllCity();
		PageHelper.getPage(cityList, "city", null, null, 10, number, this.getRequest(), null);
		return "admin/listcity";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryCityByCond.action")
	public String queryCityByCond(String cond, String name, String number) {
		City city = new City();
		if (cond != null) {
			if ("cityname".equals(cond)) {
				city.setCityname(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.cityService.getCityByLike(city), "city", nameList, valueList, 10, number, this.getRequest(), "query");
		name = null;
		cond = null;
		return "admin/querycity";
	}

	// 按主键查询数据
	@RequestMapping("getCityById.action")
	public String getCityById(String id) {
		City city = this.cityService.getCityById(id);
		this.getRequest().setAttribute("city", city);
		return "admin/editcity";
	}

	public CityService getCityService() {
		return cityService;
	}

	public void setCityService(CityService cityService) {
		this.cityService = cityService;
	}

}

public class PageHelper {

	public static void getPage(List<?> list, String name, List<String> nameList, List<String> valueList, int pageSize, String number,
	public String deleteDetailsByIds() {
		String[] ids = this.getRequest().getParameterValues("detailsid");
		for (String detailsid : ids) {
			this.detailsService.deleteDetails(detailsid);
		}
		return "redirect:/details/getAllDetails.action";
	}

	// 更新数据
	@RequestMapping("updateDetails.action")
	public String updateDetails(Details details) {
		this.detailsService.updateDetails(details);
		return "redirect:/details/getAllDetails.action";
	}

	// 显示全部数据
	@RequestMapping("getAllDetails.action")
	public String getAllDetails(String number) {
		List<Details> detailsList = this.detailsService.getAllDetails();
		PageHelper.getPage(detailsList, "details", null, null, 10, number, this.getRequest(), null);
		return "admin/listdetails";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryDetailsByCond.action")
	public String queryDetailsByCond(String cond, String name, String number) {
		Details details = new Details();
		if (cond != null) {
			if ("ordercode".equals(cond)) {
				details.setOrdercode(name);
			}
			if ("jiancaiid".equals(cond)) {
				details.setJiancaiid(name);
			}
			if ("num".equals(cond)) {
				details.setNum(name);
			}
			if ("price".equals(cond)) {
				details.setPrice(name);
			}
			if ("cityid".equals(cond)) {
				details.setCityid(name);
			}
			if ("peihuoid".equals(cond)) {
				details.setPeihuoid(name);
			}
			if ("viewdate".equals(cond)) {
				details.setViewdate(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();

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

转载请注明出处或者链接地址:https://www.qianduange.cn//article/11414.html
标签
评论
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!