ssm实战城镇道路管理系统

这是一个基于Spring+SpringMVC+MyBatis架构的城镇道路管理系统,采用MySQL数据库和JSP设计前端页面,具备道路分类、添加道路、巡查记录和评价管理等功能。开发环境包括JDK 8、IntelliJ IDEA、Tomcat 8.5.40和MySQL 5.7。
摘要由CSDN通过智能技术生成

项目介绍

本系统使用Spring+SpringMVC+MyBatis架构,数据库使用MySQL,前端页面使用jsp设计的道路管理系统,主要有道路分类管理,添加道路管理,巡查记录管理,评价管理等模块。

开发环境

  1. jdk 8
  2. intellij idea
  3. tomcat 8.5.40
  4. mysql 5.7

所用技术

  1. Spring+SpringMVC+MyBatis
  2. layui
  3. jsp

项目截图

  • 分类管理
    在这里插入图片描述

  • 添加道路
    在这里插入图片描述

  • 添加评价
    在这里插入图片描述

  • 巡查记录
    在这里插入图片描述

  • 系统介绍
    在这里插入图片描述

框架配置

  1. db.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost/urbanRoad?useUnicode=true&characterEncoding=utf-8&useSSL=false
jdbc.username=root
jdbc.password=root123
  1. applicationContext-mvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd
       http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop.xsd">

    <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 -->
    <context:component-scan base-package="com.lrfalse.controller"/>

    <mvc:interceptors>
        <mvc:interceptor>
            <!-- 需要拦截的url路径 :/order/**  这个是订单系统的url格式 -->
            <mvc:mapping path="/**" />
            <mvc:exclude-mapping path="/login"/>
            <mvc:exclude-mapping path="/*.js"/>
            <mvc:exclude-mapping path="/register"/>
            <mvc:exclude-mapping path="/logout"/>
            <bean class="com.lrfalse.interceptor.LoginInterceptor"></bean>
        </mvc:interceptor>
    </mvc:interceptors>
    <!-- 支持aop的注解 -->
    <aop:aspectj-autoproxy/>

    <!-- 启动SpringMVC的注解功能 -->
    <mvc:annotation-driven/>

    <!--静态资源放行-->
    <mvc:default-servlet-handler/>

    <!-- 定义跳转的文件的前后缀 ,视图解析器配置-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <!-- 配置文件上传解析器 -->
    <bean id="multipartResolver"
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <!-- 默认编码 -->
        <property name="defaultEncoding" value="utf-8"/>
        <!-- 文件大小最大值 -->
        <property name="maxUploadSize" value="10485760000"/>
    </bean>
</beans>

  1. applicationContext-service.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <import resource="classpath*:applicationContext-mapper.xml"/>
    <!--扫描的包-->
    <context:component-scan base-package="com.lrfalse.service"/>
</beans>  
  1. applicationContext-mapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
    <!-- Jdbc配置文件 -->
    <context:property-placeholder location="classpath:db.properties" />
    <!-- 数据源dataSource -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <!--maxActive: 最大连接数量 -->
        <property name="maxActive" value="150" />
        <!--minIdle: 最小空闲连接 -->
        <property name="minIdle" value="5" />
        <!--maxIdle: 最大空闲连接 -->
        <property name="maxIdle" value="20" />
        <!--initialSize: 初始化连接 -->
        <property name="initialSize" value="30" />
        <!--maxWait: 超时等待时间以毫秒为单位 1000等于60秒 -->
        <property name="maxWait" value="1000" />
        <!-- 在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位. -->
        <property name="timeBetweenEvictionRunsMillis" value="10000" />
        <!-- 在每次空闲连接回收器线程(如果有)运行时检查的连接数量 -->
        <property name="numTestsPerEvictionRun" value="10" />
        <!-- 1000 * 60 * 30 连接在池中保持空闲而不被空闲连接回收器线程 -->
        <property name="minEvictableIdleTimeMillis" value="10000" />
        <property name="validationQuery" value="SELECT NOW() FROM DUAL" />
    </bean>
    <!--Mybatis核心对象-->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!-- 注入数据源 -->
        <property name="dataSource" ref="dataSource" />
        <!-- 配置mybatis (mapper)映射器路径 -->
        <property name="mapperLocations" value="classpath*:mapper/*Mapper.xml" />
        <!--引用mybatis的核心配置文件-->
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
        <!-- 配置mybatis 类型别名 -->
        <property name="typeAliasesPackage">
            <value>
                com.lrfalse.entity
                com.lrfalse.query
            </value>
        </property>
        <property name="plugins">
            <array>
                <bean class="com.github.pagehelper.PageHelper">
                    <property name="properties">
                        <value>
                            dialect=mysql
                            reasonable=true
                        </value>
                    </property>
                </bean>
            </array>
        </property>
    </bean>
    <!--注入映射器,一劳永逸的做法-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.lrfalse.mapper"></property>
    </bean>
    <!--事务管理-->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--以注解的方式进行事务管理-->
    <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

业务代码

  1. 道路信息保存
@RequestMapping("/save")
@ResponseBody
public AjaxResult save(RoadReq roadReq){
    try {
        Road road=new Road();	//主道路信息
        BeanUtil.copyProperties(roadReq,road);

        Roadway roadway=new Roadway();
        BeanUtil.copyProperties(roadReq,roadway);//车行道对象
        roadway.setId(roadReq.getRoadwayId());

        Separator separator=new Separator();
        BeanUtil.copyProperties(roadReq,separator);//分隔带
        separator.setId(roadReq.getSeparatorId());

        Sidewalk sidewalk=new Sidewalk();
        BeanUtil.copyProperties(roadReq,sidewalk);//人行道
        sidewalk.setId(roadReq.getSidewalkId());

        AncillaryFacilities ancillaryFacilities=new AncillaryFacilities();
        BeanUtil.copyProperties(roadReq,ancillaryFacilities);//附属设施对象
        ancillaryFacilities.setId(roadReq.getAncillaryFacilitiesId());

        if(road.getId()!=null){
            roadService.update(road);
            iAncillaryFacilitiesService.update(ancillaryFacilities);
            iRoadwayService.update(roadway);
            iSeparatorService.update(separator);
            iSidewalkService.update(sidewalk);
            return new AjaxResult("修改成功!");
        }else{
            roadService.add(road);
            iAncillaryFacilitiesService.add(ancillaryFacilities);
            iRoadwayService.add(roadway);
            iSeparatorService.add(separator);
            iSidewalkService.add(sidewalk);
            return new AjaxResult("保存成功!");
        }
    } catch (Exception e) {
        e.printStackTrace();
        return new AjaxResult("保存失败:"+e.getMessage(),-10002);
    }
}

//前端jsp代码

<div class="layui-row" id="zq_formpopbox" style="position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;color: #007DDB">
        <legend>街道基础信息</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" action="">
        <div class="layui-col-md3">
            <div class="layui-form-item">
                <label class="layui-form-label">道路名称</label>
                <div class="layui-input-block">
                    <input type="text" name="roadName" id="roadName" lay-verify="required" placeholder="请输入道路名称"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">道路编号</label>
                <div class="layui-input-block">
                    <input type="text" name="roadNum" id="roadNum" lay-verify="required" placeholder="请输入道路编号"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">道路走向</label>
                <div class="layui-input-block">
                    <input type="text" name="roadTo" id="roadTo" lay-verify="required" placeholder="请输入道路走向"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">起点</label>
                <div class="layui-input-block">
                    <input type="text" name="origin" id="origin" lay-verify="required" placeholder="请输入起点"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">终点</label>
                <div class="layui-input-block">
                    <input type="text" name="destination" id="destination" lay-verify="required" placeholder="请输入终点"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-col-md3">
            <div class="layui-form-item">
                <label class="layui-form-label">设计单位</label>
                <div class="layui-input-block">
                    <input type="text" name="architect" id="architect" lay-verify="required" placeholder="请输入设计单位"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">施工单位</label>
                <div class="layui-input-block">
                    <input type="text" name="constructionOrganization" id="constructionOrganization"
                           lay-verify="required" placeholder="请输入施工单位" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class=&#
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序帮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值