SSM框架毕设项目回顾

2020-06-12  本文已影响0人  JayMeWangGL

使用技术

在毕业设计程序中主要使用了SSM框架、Spring-Securtiy、Ajax、HTML、CSS、JS、JSP等技术


SSM整合

在resources目录下,创建applicationContext.xml进行Spring和Mybatis的整合。其中包括:
<context:component-scan base-package="com.wgl.dao"></context:component-scan>
<context:component-scan base-package="com.wgl.service"></context:component-scan>

由于我使用的mysql版本8.0以上,所以采用com.mysql.cj.jdbc.Driver包进行连接,并在Url路径中添加serverTimezone

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="com.mysql.cj.jdbc.Driver"></property>
        <property name="jdbcUrl" value="jdbc:mysql:///XXXXXX?serverTimezone=Asia/Shanghai"></property>
        <property name="user" value="root"></property>
        <property name="password" value="XXXX"></property>
    </bean>
    <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
    </bean>
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.wgl.dao"></property>
    </bean>
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"></property>
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>
在resources目录下,创建springmvc.xml进行Spring和SpringMVC的整合。其中包括:
<context:component-scan base-package="com.wgl.controller"></context:component-scan>
    <bean id="resourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/pages/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
    <mvc:resources mapping="/css/**" location="/css/"></mvc:resources>
    <mvc:resources mapping="/img/**" location="/img/"></mvc:resources>
    <mvc:resources mapping="/js/**" location="/js/"></mvc:resources>
    <mvc:resources mapping="/plugins/**" location="/plugins/"></mvc:resources>
    <mvc:annotation-driven></mvc:annotation-driven>
    <aop:aspectj-autoproxy proxy-target-class="true"/>

项目思路

通过链接(href)或者表格的action来发送Ajax请求,将消息传递到controller中进行处理

action = "${pageContext.request.contextPath}/user/register"

href = "${pageContext.request.contextPath}/route/route_all"

后台处理完数据后通过ModelAndView进行数据转发和页面跳转

@RequestMapping("/route_all")
    public ModelAndView route_all() throws Exception {
        ModelAndView mv =  new ModelAndView();
        List<Route> routeList = routeService.find_All();
        mv.addObject("routeList",routeList);//数据
        mv.setViewName("route_list");//视图
        return mv;
    }
上一篇 下一篇

猜你喜欢

热点阅读