java:Spring框架4(Project,ER图)
2024-10-07 02:39:36
1.Project:
ER图:
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: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-4.3.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/tx/spring-tx.xsd">
<!-- dataSource数据源 -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/test">
</property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean> <!-- sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>cn/zzsxt/myblog/model/TblPhoto.hbm.xml</value>
<value>cn/zzsxt/myblog/model/TblUser.hbm.xml</value>
<value>cn/zzsxt/myblog/model/TblArticle.hbm.xml</value>
<value>
cn/zzsxt/myblog/model/TblArticletype.hbm.xml
</value>
</list>
</property>
</bean> <!-- hibernateTemplate ,并注入sessionFactory-->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <!-- DAO -->
<bean id="tblUserDao" class="cn.zzsxt.myblog.dao.impl.TblUserDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
<bean id="tblArticleTypeDao" class="cn.zzsxt.myblog.dao.impl.TblArticleTypeDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
<bean id="tblArticleDao" class="cn.zzsxt.myblog.dao.impl.TblArticleDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
<bean id="tblPhotoDao" class="cn.zzsxt.myblog.dao.impl.TblPhotoDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean> <!-- Service -->
<bean id="tblUserService" class="cn.zzsxt.myblog.service.impl.TblUserServiceImpl">
<property name="tblUserDao" ref="tblUserDao"></property>
</bean>
<bean id="tblArticleTypeService" class="cn.zzsxt.myblog.service.impl.TblArticleTypeServiceImpl">
<property name="tblArticletypeDao" ref="tblArticleTypeDao"></property>
</bean>
<bean id="tblArticleService" class="cn.zzsxt.myblog.service.impl.TblArticleServiceImpl">
<property name="articleDao" ref="tblArticleDao"></property>
</bean>
<bean id="tblPhotoService" class="cn.zzsxt.myblog.service.impl.TblPhotoServiceImpl">
<property name="tblPhotoDao" ref="tblPhotoDao"></property>
</bean> <!-- Action -->
<bean id="tblUserAction" class="cn.zzsxt.myblog.action.TblUserAction" scope="prototype">
<property name="tblUserService" ref="tblUserService"></property>
</bean>
<bean id="tblArticleTypeAction" class="cn.zzsxt.myblog.action.ArticleTypeAction" scope="prototype">
<property name="articleTypeService" ref="tblArticleTypeService"></property>
</bean>
<bean id="tblArticleAction" class="cn.zzsxt.myblog.action.ArticleAction" scope="prototype">
<property name="articleTypeService" ref="tblArticleTypeService"></property>
<property name="articleService" ref="tblArticleService"></property>
</bean>
<bean id="tblPhotoAction" class="cn.zzsxt.myblog.action.TblPhotoAction" scope="prototype">
<property name="photoService" ref="tblPhotoService"></property>
</bean> <!-- spring声明式事务 -->
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* cn.zzsxt.myblog.service.*.*(..))" id="serviceMethod"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod"/>
</aop:config>
</beans>
struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<constant name="struts.multipart.maxSize" value="20971520"></constant>
<package name="myblog" extends="struts-default">
<!-- struts2.3以前的版本不需要添加,struts2.5以后的版本添加通配符调用的访问限制 -->
<global-allowed-methods>regex:.*</global-allowed-methods> <action name="user-*" class="tblUserAction" method="{1}">
<result name="success">/index.jsp</result>
<result name="login">/login.jsp</result>
</action>
<action name="type-*" class="tblArticleTypeAction" method="{1}">
<result name="success" type="redirectAction">type-list</result>
<result name="list">/type_list.jsp</result>
</action> <action name="article-*" class="tblArticleAction" method="{1}">
<result name="add">/article_add.jsp</result>
<result name="success" type="redirectAction">article-list</result>
<result name="list">/article_list.jsp</result>
</action> <action name="photo-*" class="tblPhotoAction" method="{1}">
<result name="success" type="redirectAction">photo-list</result>
<result name="list">/photo_list.jsp</result>
</action>
</package>
</struts>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>myBlog</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 解决Post请求乱码的过滤器 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 解决session拦截加载问题:OSIV(OpenSessionInViewFilter) -->
<filter>
<filter-name>isovFilter</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>isovFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--
struts2核心过滤器
struts2.3.3的核心过滤器:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
struts2.5核心过滤器:org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
最新文章
- 使用 Swagger 自动生成 ASP.NET Core Web API 的文档、在线帮助测试文档(ASP.NET Core Web API 自动生成文档)
- dSYM 文件分析工具
- GetViewUrl
- iOS中push视图的时候,屏幕中间会出现一条灰色的粗线的解决方案
- 浅析正则表达式模式匹配的String方法
- 如何生成ipa文件
- Oracle RAC 并发与架构
- 标准库类型vector
- LINQ的基本用法
- ListView小坑
- struts2 action接收请求参数和类型转换
- unity3d ipv6支持
- ABP学习笔记总汇
- Dynamics 365-N:N Relationship的记录处理
- 新建SpringBoot项目运行页面报错Whitelabel Error Page This application has no explicit mapping for /error, so yo
- 3ds max学习笔记(九)-- 实例操作(路径阵列)
- idea中切换svn地址不起作用
- Spring Boot 2(一):Spring Boot 2.0新特性
- cad2014卸载/安装失败/如何彻底卸载清除干净cad2014注册表和文件的方法
- Activity猫的一生-故事解说Activity生命周期
热门文章
- oracle exp 和 imp 数据和表结构互相独立导出导入
- eclipse查看jsp出现failed to create the part&#39;s controls的解决方法
- No training required: Exploring random encoders for sentence classification(解析)
- 网络编程与socket
- Springboot项目全局异常统一处理
- Newsgroups数据集研究
- web前端_css01
- CPU风扇转速异常
- HGOI 20190519 题解
- jQuery_val()操作