基于SSM写的一个简易博客(练手小项目)

前端使用了Bootstrap和jquery组件编写,后端是集成了Spring+SpringMVC+MyBatis的SSM框架,实现了基本登录注册功能,博客的增删改查和模糊查询功能的功能,还有用户个人信息添加修改等功能。


 下面是一些页面展示图

1.博客首页

2.登录页面

3.注册的页面

4.个人主页

5.新增博客页面

6.模糊查询页面

7.简介页面

 8.更改博客页面

9.查看博客页面


下面是一些代码图

1.Controller层

2.Service层

 3.Dao层和Mapper文件

 

 4.项目的结构和实体类


配置文件代码

spring-service

<?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">

    <!-- 扫描service相关的bean -->
    <context:component-scan base-package="com.qjj.ssm.service" />

    <!--UserServiceImpl注入到IOC容器中-->
    <bean id="userService" class="com.qjj.ssm.service.UserServiceImpl">
        <property name="userDao" ref="userDao"/>
    </bean>
    <!--UserServiceImpl注入到IOC容器中-->
    <bean id="blogService" class="com.qjj.ssm.service.BlogServiceImpl">
        <property name="blogDao" ref="blogDao"/>
    </bean>

    <!-- 配置事务管理器 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <!-- 注入数据库连接池 -->
        <property name="dataSource" ref="dataSource" />
    </bean>

</beans>

 

spring-mvc

<?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: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
   https://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!-- 配置SpringMVC -->
    <!-- 1.开启SpringMVC注解驱动 -->
    <mvc:annotation-driven />
    <!-- 2.静态资源默认servlet配置-->
    <mvc:default-servlet-handler/>

    <!-- 3.配置jsp 显示ViewResolver视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <!-- 4.扫描web相关的bean -->
    <context:component-scan base-package="com.qjj.ssm.controller" />

    <mvc:resources mapping="/css/**" location="/statics/css/"/>
    <mvc:resources mapping="/js/**" location="/statics/js/"/>
    <mvc:resources mapping="/image/**" location="/statics/images/"/>
</beans>

applicationContext.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: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/aop http://www.springframework.org/schema/aop/spring-aop.xsd
                            http://www.springframework.org/schema/tx http://www.springframework.org/schema/aop/spring-tx.xsd">

        <import resource="spring/spring-dao.xml"/>
        <import resource="spring/spring-mvc.xml"/>
        <import resource="spring/spring-service.xml"/>
</beans>

博客可能做的比较简易,还有很多后续的功能没有实现,只是当一个ssm的练手小项目来分享给大家和记录一下自己学习的一个过程,如果有问题或者建议都可以在下面留言或者私信我,感谢大家的支持。

                                                                                                                                QQ:292944931