欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

基于SSM开发的垃圾分类管理系统 JAVA MySQL

程序员文章站 2022-12-04 14:25:56
10109基于SSM开发的垃圾分类管理系统代码:鏈-椄:https://pan@baidu@com/s/1wAjL3PK78Bv9866q-B6kuw (把@换成 . 就可正常访问)趧-紶-碼:1226f/u枝此段-吶傛打开baidu網盤手机App,caozuo更方便哦技术Spring + SpringMVC + Mybatis工具eclipse + tomact + mysql + jdk功能详情功能详情小区管理垃圾分类信息垃圾站信息垃圾运输信息...

10109基于SSM开发的垃圾分类管理系统

代码:
鏈-椄:https://pan@baidu@com/s/1wAjL3PK78Bv9866q-B6kuw (把@换成 . 就可正常访问)
趧-紶-碼:1226
f/u枝此段-吶傛打开baidu網盤手机App,caozuo更方便哦

技术
Spring + SpringMVC + Mybatis

工具
eclipse + tomact + mysql + jdk

功能详情

功能详情
小区管理
垃圾分类信息
垃圾站信息
垃圾运输信息
报修管理
投诉管理
个人信息
修改密码
退出系统

系统相关截图

基于SSM开发的垃圾分类管理系统 JAVA MySQL
基于SSM开发的垃圾分类管理系统 JAVA MySQL

package com.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dao.UserDAO;
import com.model.User;

@Service(“userService”)
public class UserServiceImp implements UserService {
@Autowired
private UserDAO userDAO;

@Override
public boolean exits(String username){
	List<User> userList = userDAO.findByUsername(username);
	if(userList.size()>0)
		return true;
	else
		return false;
}

@Override
public List<User> queryUsers(String username){
	if(username == null || "".equals(username))
		return userDAO.findAllUsers();
	else return userDAO.queryByUsername(username);
}

@Override
 public User getUser(Integer id){
		return userDAO.getUser(id);
}

@Override
@Transactional
public void save(User user){
	userDAO.save(user);
}

@Override
@Transactional
public void modifyUser(User user){
	userDAO.update(user);
}

@Override
@Transactional
public void deleteUser(Integer id){
	userDAO.delete(id);
}

}
package com.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.model.User;
import com.opensymphony.xwork2.ActionSupport;
import com.service.UserService;

@Component(“userAction”)
@Scope(“prototype”)
public class UserAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
private UserService userService;

private User user;

private String searchText;

private List<User> users;

public User getUser() {
	return user;
}
public void setUser(User user) {
	this.user = user;
}
public UserService getUserService() {
	return userService;
}
@Resource
public void setUserService(UserService userService) {
	this.userService = userService;
}

public String addUser(){
	if(userService.exits(user.getUsername())){
		return ERROR;
	}
	userService.save(user);
	return SUCCESS;
}

public String queryUser(){
	searchText = getParam("queryText");
	users = userService.queryUsers(searchText);
	return SUCCESS;
}

public String editUser(){
	try {
		Integer param = Integer.parseInt(getParam("param"));
		if(param == 0){
			Integer id = Integer.parseInt(getParam("id"));
			user = userService.getUser( id);
			return "editUser";
		}else if(param == 1){
			userService.modifyUser(user);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return SUCCESS;
}

public String deleteUser(){
	try {
		Integer param = Integer.parseInt(getParam("id"));
		userService.deleteUser(param);
	} catch (Exception e) {
		e.printStackTrace();
	}
	return queryUser() ;
}
public String getSearchText() {
	return searchText;
}
public void setSearchText(String searchText) {
	this.searchText = searchText;
}
protected String getParam(String key){
	return ServletActionContext.getRequest().getParameter(key);
}
public List<User> getUsers() {
	return users;
}
public void setUsers(List<User> users) {
	this.users = users;
}

}

<?xml version="1.0" encoding="UTF-8"?>

<!-- 用注解方法注入bean 上边schemaLocation的三条语句顺序很重要,否则报错 -->
<context:annotation-config />
<context:component-scan base-package="com" />

<!-- 数据库连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
	destroy-method="close">
	<property name="driverClassName" value="com.mysql.jdbc.Driver" />
	<property name="url" value="jdbc:mysql://localhost:3306/mydb?useUnicode=true&amp;characterEncoding=UTF-8" />
	<property name="username" value="root" />
	<property name="password" value="123456" />
</bean>

<!-- 配置sessionFactory ,数据库配置在hibernate.cfg.xml中-->
<!--LocalSessionFactoryBean 加载bean方式 <mapping resource="com/model/User.hbm.xml"/>
    AnnotationSessionFactoryBean 加载bean方式 <mapping class="com.model.User"/> ,它主要功能是取消了hbm.xml文件
 -->
<bean id="sessionFactory"
	class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
	<property name="dataSource" ref="dataSource" />
	<!-- 配置实体描述文件 -->
	<property name="mappingResources">
		<list>
			<value>com/model/User.hbm.xml</value>
		</list>
	</property>
	<!--扫描com.cuangwu包下以及子包种有 @Service @Controller @Repository @Component  注解的类,一旦发现,则将其纳入到spring容器中管理 
        此spring.jar必须是 Spring2.5以上版本的,因为,Spring2.5之前org.springframework.orm.hibernate3.LocalSessionFactoryBean类中,
        并没有 packageToScan 这个属性,只有mappingResuorces这个属性。而packageToScan这个属性正是映射包中的类,而mappingResuorces只是映射某个文件。-->
	<!-- <property name="packagesToScan" > <list> <value>com.model</value> 
		</list> </property> -->
	<property name="hibernateProperties">
		<props>
			<prop key="hibernate.format_sql">true</prop>
			<prop key="hibernate.hbn2dd1.auto">update</prop>
			<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
		</props>
	</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
	<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- 配置事务管理器 -->
<bean id="transactionManager"
	class="org.springframework.orm.hibernate3.HibernateTransactionManager">
	<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
	<tx:attributes>
		<tx:method name="find*" read-only="true" />
		<tx:method name="add*" propagation="REQUIRED" />
		<tx:method name="delete*" propagation="REQUIRED" /> 
        <tx:method name="update*" propagation="REQUIRED" /> 
	</tx:attributes>
</tx:advice>
<!-- aop代理设置--> 
<aop:config>
	<aop:pointcut expression="execution(public * com.service..*.*(..))"
		id="myPointcut" />
	<aop:advisor advice-ref="txAdvice" pointcut-ref="myPointcut" />
</aop:config>

<?xml version="1.0" encoding="UTF-8" ?>

success.jsp fail.jsp index.jsp success.jsp fail.jsp editUser.jsp success.jsp

本文地址:https://blog.csdn.net/m0_52452123/article/details/109644368