eclipse ssh2框架实例
1个回答
展开全部
启动tomcat,分别输入hello和world,提交,结果为hello和world。说明struts2和spring整合成功。
Struts+Spring整合实现,接下来继续整合Hibernate
前面已经讲述了Struts2+Spring整合,这里我们接着整合Hibernate
整合Hibernate
1)导入Hibernate3.1的jar包:antlr-2.7.6.jar,commons-collections-3.1.jar,dom4j-1.6.1.jar,javassist-3.4.GA.jar,jta-1.1.jar,hibernate3.jar,slf4j-api-1.5.6.jar,slf4j-log4j12-1.5.6.jar,log4j-1.2.13.jar。暂时导入这些jar包,到时候需要再倒入。
2)将spring的配置文件applicationContext-*.xml文件放置在OA工程的src目录下,这里我们有三个:
applicationContext-action.xml,applicationContext-beans.xml,applicationContext-common.xml
3)在web.xml里面配置
Xml代码
<!-- when application server started,loading the applicationContext-*.xml
-->
<context-param>
<param-name>contextConfigLoaction</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>
<!-- integerate spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- let spring manage hibernate's session,that we can focus bussiness
layer -->
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<!-- configrate struts2 core filter -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- configurate web character encoding -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
Struts+Spring整合实现,接下来继续整合Hibernate
前面已经讲述了Struts2+Spring整合,这里我们接着整合Hibernate
整合Hibernate
1)导入Hibernate3.1的jar包:antlr-2.7.6.jar,commons-collections-3.1.jar,dom4j-1.6.1.jar,javassist-3.4.GA.jar,jta-1.1.jar,hibernate3.jar,slf4j-api-1.5.6.jar,slf4j-log4j12-1.5.6.jar,log4j-1.2.13.jar。暂时导入这些jar包,到时候需要再倒入。
2)将spring的配置文件applicationContext-*.xml文件放置在OA工程的src目录下,这里我们有三个:
applicationContext-action.xml,applicationContext-beans.xml,applicationContext-common.xml
3)在web.xml里面配置
Xml代码
<!-- when application server started,loading the applicationContext-*.xml
-->
<context-param>
<param-name>contextConfigLoaction</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>
<!-- integerate spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- let spring manage hibernate's session,that we can focus bussiness
layer -->
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<!-- configrate struts2 core filter -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- configurate web character encoding -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询