SSH三大框架整合后的配置文件详解

关于SSH三大框架整合——配置文件方式、配置文件+注解方式 1. Spring整合Struts2框架,存在2种方式(Action对象由哪个框架创建的) * 导入开发的jar包 * struts2-spring-plugin-2.3.24.jar * Action对象可以由Struts2框架创建,默认的方式 * 因为导入struts2-spring-plugin-2.3.24.jar包,提供类struts-plugin.xml配置文件, 该文件 阅读详情

学习三大框架Struts2 、 Hibernate 、 Spring时,涉及到三大框架的配置文件以及整合。今天就来详细写写三大框架配置文件的详细内容。

一 Spring的applicationContext.xml中的配置:


<?xmlversion="1.0"encoding="UTF-8"?>

<beansxmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xmlns:p="http://www.springframework.org/schema/p"

xsi:schemaLocation="http://www.springframework.org/schema/beans 

      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

      http://www.springframework.org/schema/context

           http://www.springframework.org/schema/context/spring-context-3.0.xsd

           http://www.springframework.org/schema/aop

           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

           http://www.springframework.org/schema/tx

           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">


<!-- 配置由Spring IoC容器托管对象对应的被注解的类所在的包 -->

<context:component-scanbase-package="com.leipengzj"/>

<!-- 配置通过自动生成代理类实现AOP功能 -->

<aop:aspectj-autoproxy/>


<!--DateSource 使用c3p0连接池-->

<beanid="dateSource"class="com.mchange.v2.c3p0.ComboPooledDateSource"destroy-method="close">

<propertyname="driverClass"value="com.mysql.jdbc.Driver"></property>

<propertyname="jdbcUrl"value="jdbc:mysql:/3306/leiepngzj_table"></property>

<propertyname="user"value="root"></property>

<propertyname="password"value="root"></property>

</bean>

<!-- SessionFactory 配置  配置Spring提供的支持注解ORM映射的Hibernate会话工厂-->

<beanid="sessionFactory"class="org.springframework.orm.hibernate3.annotation">

<propertyname="dateSource"ref="dateSource"></property>

<propertyname="congifLocation"value="classpath:hibernate.cfg.xml"></property>

</bean>

<!-- 配置spring基于注解的声明式事务管理 -->

<beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 

<!-- 通过setter注入Hibernate会话工厂 -->

<propertyname="sessionFactory"ref="sessionFactory"></property>

</bean>

<tx:annotation-driventransaction-manager="transactionManager"/>

</beans>


二 Hibernate.cfg.xml配置:

  

<?xmlversion='1.0'encoding='UTF-8'?>

<!DOCTYPEhibernate-configuration PUBLIC

          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<!-- Generated by MyEclipse Hibernate Tools.                   -->

<hibernate-configuration>


    <session-factory>

    <!-- 数据库连接信息 ,其他的写到了spring配置文件中去 -->

       <propertyname="dialect">org.hibernate.dialect.MySQLDialect</property>

        <!-- 其他配置 -->

        <propertyname="show_sql">true</property>

       <propertyname="hbm2ddl.auto">update</property>

        <!-- 导入映射配置 -->

        <mappingresource="../../.hbm.xml"/>

        <mappingresource="../../.hbm.xml"/>

        <mappingresource="../../.hbm.xml"/>

        

    </session-factory>


</hibernate-configuration>


三 struts.xml中的配置文件:


<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPE strutsPUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN""http://struts.apache.org/dtds/struts-2.1.dtd">

<struts>

<!-- 配置为开发模式 -->

<constantname="struts.devMode"value="true"></constant>

     <!-- 配置扩展名为action -->

<constantname="struts.action.extension"value="action"></constant>

<!-- 当struts配置文件修改时,系统是否自动重新加载该文件,默认false,开发阶段最好打开 -->

<constantname="struts.configuration.xml.reload"value="true"></constant>

<!-- 全局视图 -->

<packagename="LunTanSystem"extends="struts-default">

<global-results>

<resultname="error">/error.jsp</result>

<resultname="ajax">/ajax.jsp</result>

<resultname="noLogin">/login.jsp</result>

</global-results>

<!-- 当与action整合后,class属性写的就是Spring中bean的属性 -->

<actionname="test"class="testAction">

<resultname="success">/test.jsp</result>

</action>

</package>


</struts>    


四 web.xml配置文件的编写:

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

<web-app version="2.5" 

xmlns="http://java.sun.com/xml/ns/javaee" 

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

  <display-name></display-name>

  <!-- 配置Struts2的主过滤器 -->

    <filter>

  <filter-name>struts2</filter-name>

  <filter-class>

  org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

  </filter-class>

  </filter>

  <filter-mapping>

  <filter-name>struts2</filter-name>

  <url-pattern>/*</url-pattern>

  </filter-mapping>


   <!--配置Spring的监听器,用于初始化ApplicationContext.xml  -->

  <listener>

  <listener-class>org.springframework.web.context.ContextLoader</listener-class>

  </listener>

  <context-param>

  <param-name>contextConfigLocation</param-name>

  <param-value>classpath:applicationContext*.xml</param-value>

  </context-param>

  

  <welcome-file-list>

    <welcome-file>index.jsp</welcome-file>

  </welcome-file-list>

</web-app>



SSH框架整合实战 本文还有配套的精品资源,点击获取 简介:SSH整合将Struts2、Spring和Hibernate三大框架集成,构建MVC架构的Java Web应用。本课程设计项目提供完整的整合流程实战,涵盖环境配置、Struts2、Spring、Hibernate的配置和整合,以及MVC模式的代码编写。通过本项目,学生将掌握SSH框架的应用,提升Web开发技能,为企业级应用开发奠定基础... 阅读详情

相关推荐

ssh框架配置文件的实例

ssh框架配置文件的实例,教会大家使用ssh框架的xml配置

ssh配置文件详解

简单来说,ssh是一种网络协议,用于计算机之间的加密登录。 如果一个用户从本地计算机,使用ssh协议登录另一台远程计算机,我们就可以认为,这种登录是安全的,即使被中途截获,密码也不会泄露。 需要指出的是,ssh只有一种协议,存在多种实现,既有商业实现,也有开源实现。

君逍遥o 7769

什么是 WhatsApp云控 WhatsApp群发,WhatsApp协议,他们有什么区别?

下面我们sensws讲解下什么是WhatsApp云控 WhatsApp群发,WhatsApp协议

sendws的博客 3875

ssh安装与配置(详解版)

主要对openssh的安装,客户端和服务器的常见命令以及常用配置进行了超万字的详细总结

余识- 8万+

CAS5和CAS6自定义异常提示消息

CAS自定义异常提示消息

weixin_42949219的博客 979

多臂老虎机——入门强化学习

多臂老虎机(Multi-Armed Bandit,MAB)问题是强化学习的经典入门例子,也是理解探索与利用(exploration-exploitation)平衡的重要案例。

qq_56683019的博客 2460

Linux:SSH服务配置文件详解

SSH服务配置文件详解 SSH客户端配置文件 /etc/ssh/ssh——config 配置文件概要 Host * #选项“Host”只对能够匹配后面字串的计算机有效。“*”表示所有的计算机。 ForwardAgent no #设置连接是否经过验证代理(如果存在)转发给远程计算机。 ForwardX11 no #设置X11...

aji1978的博客 883

MDK开发篇:基于立创逻辑派FPGA-G1与Cortex-M1软核的按键控制LED实战

本文详细介绍了基于立创逻辑派FPGA-G1开发板与高云Cortex-M1软核的完整开发流程。通过Gowin云源软件配置软核系统与GPIO外设,并在Keil MDK环境中编写按键控制LED的C程序,最终实现程序固化与上电自启动。教程涵盖硬件配置、软件开发、在线调试与固化部署全步骤,帮助STM32开发者快速上手FPGA软核开发。

weixin_42103128的博客 149

<Linux>《OpenSSH 客户端配置文件ssh_config详解》

OpenSSH ssh_config

Else 的博客 1万+

内存预取黑科技:__builtin_prefetch在数据库和游戏开发中的高阶用法

本文深入探讨了GCC内置函数`__builtin_prefetch`在数据库和游戏开发中的高阶应用。通过LevelDB的SSTable文件读取优化和UE5引擎场景数据流式加载的实战案例,详细解析了预取参数调优的艺术,并借助perf工具量化分析了不同策略的性能提升效果。文章还介绍了与`__builtin_expect`等内置函数的协同优化技巧,帮助开发者最大化缓存命中率。

weixin_29019241的博客 417

TCN(Temporal Convolutional Networks)时序卷积网络详解及代码

TCN(Temporal Convolutional Networks)时序卷积网络详解及代码

zhulewen的博客 7884

ssh三大框架整合——配置文件

Spring hibernate struts2 三大框架整合配置文件:applicationContext.xml文件:基于xml配置 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="ht

gr1021的博客 1814

【数据同化第一期】基本概念介绍

【数据同化第一期】基本概念介绍

WW、forever的博客 1904

ssh三大框架整合-配置文件

三 ssh三大框架配置文件 3-1. Struts2需要的配置文件 web.xml配置struts2的核心过滤器 struts.xml <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "htt

肆尾葱的博客 647

电动汽车远程监控与诊断软件:BMW ConnectedDrive EV远程监控二次开发_7.数据安全与隐私保护

数据加密是保护数据安全的重要手段之一。在电动汽车远程监控与诊断软件中,加密技术可以确保数据在传输过程中的安全性和完整性。常见的加密技术包括对称加密和非对称加密。

zhubeibei168的博客 884

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

ssh三大框架整合配置文件及测试代码

配置文件applicationContext.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/

hackerlee 399

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

SSH三大框架整合使用的配置文件 注解实现

1 Struts。xml 使用拦截器 <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/str...

weixin_30858241的博客 96

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

SSH三大框架整合maven配置文件pom.xml的写法

&lt;!-- 属性: 定义版本的常量,方便修改 --&gt;  &lt;properties&gt;    &lt;!-- 屬性名稱,方便下面使用OGNL表達式取值 --&gt;    &lt;spring.version&gt;4.2.4.RELEASE&lt;/spring.version&gt;    &lt;hibernate.version&gt;5.0.7.Final&lt;/hib...

yxl_1207的博客 839

SSH三大框架整合

SSH三大框架整合 头文件 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"> hibernate.cfg.xml <?xml version="1.0

qq_45187522的博客 146

SSH2三大框架整合

关于ssh三大框架整合 1:顺序:hibernate -->spring --> struts2 2: hibernate           ❶下面这个就不要了                         ❷下面这个SessionFactory也不要了                     3:下面导入Spring,一

靳江海 639

JAVA三大框架/SSH三大框架搭建

SSH整合步骤 第一步: 新建WEB工程,导入Struts2 .jar包      操作步骤:  (1)右击项目名称 在出现的菜单中选择myEclipse 的 下级菜单  ADD Struts Capabliities 命令 弹出 导入对话框 (2)  在ADD Struts Capabliities对话框中选择Struts2.1的版本出现Struts2的名字   (3)点击完成,导入S

aihongmingqi的专栏 3048
上一篇: JavaEE面试题,
下一篇: 登陆页面书写
花开富贵❀
博客等级 码龄12年 4粉丝 8原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值