Spring
在WEB-INF目录下,添加配置文件 applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<!-- action -->
<bean id="loginAction" class="action.LoginAction">
<property name="clGysDao" ref="clGysDao"></property>
<property name="clGrzxxDao" ref="clGrzxxDao"></property>
<property name="clZxcmxDao" ref="clZxcmxDao" ></property>
<property name="clGgzxcDao" ref="clGgzxcDao"></property>
<property name="clCzDao" ref="clCzDao"></property>
</bean>
<bean id="clgysAction" class="action.ClGysAction">
<property name="clGysDao" ref="clGysDao"></property>
</bean>
<bean id="clGrzxxAction" class="action.ClGrzxxAction">
<property name="clGrzxxDao" ref="clGrzxxDao"></property>
<property name="clClgrmxDao" ref="clClgrmxDao"></property>
<property name="ywYwlsDao" ref="ywYwlsDao"></property>
<property name="clGgzxcDao" ref="clGgzxcDao"></property>
</bean>
<bean id="xcrzAction" class="action.XcrzAction">
<property name="clCzDao" ref="clCzDao"></property>
<property name="clGgzxcDao" ref="clGgzxcDao"></property>
<property name="ywYwlsDao" ref="ywYwlsDao"></property>
<property name="clCldpmxDao" ref="clCldpmxDao"></property>
</bean>
<bean id="clczAction" class="action.ClCzAction">
<property name="clCzDao" ref="clCzDao"></property>
</bean>
<bean id="xxcxAction" class="action.XxcxAction">
<property name="clCdDao" ref="clCdDao"></property>
<property name="clCzDao" ref="clCzDao"></property>
</bean>
<!-- dao -->
<bean id="clCdDao" class="dao.ClCdDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="clCldpmxDao" class="dao.ClCldpmxDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="clCzDao" class="dao.ClCzDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="clGgzxcDao" class="dao.ClGgzxcDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="ywYwlsDao" class="dao.YwYwlsDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="clZxcmxDao" class="dao.ClZxcmxDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="clClgrmxDao" class="dao.ClClgrmxDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="clGysDao" class="dao.ClGysDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="clGrzxxDao" class="dao.ClGrzxxDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!--xxxxxxxxxxxxxxxxxxxxxxxxxxx -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">readOnly</prop>
</props>
</property>
<property name="transactionManager" ref="transactionManager"></property>
</bean>
<bean id="autoproxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames" value="*Dao"></property>
<property name="interceptorNames" value="transactionInterceptor"></property>
<!-- 对类的代理 -->
<property name="proxyTargetClass" value="true"></property>
</bean>
</beans>
在src目录下:
创建 hibernate.cfg.xml 文件
Hibernate 一般采取制动生成 hibernate.cfg.xml 与 model.hbm.xml 映射文件
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-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>
<property name="connection.username">scott</property>
<property name="connection.url">
jdbc:oracle:thin:@localhost:1521:orcl
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="myeclipse.connection.profile">oracle</property>
<property name="connection.password">tiger</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="model/ClGys.hbm.xml" />
<mapping resource="model/ClGrzxx.hbm.xml" />
<mapping resource="model/ClClgrmx.hbm.xml" />
<mapping resource="model/ClZxcmx.hbm.xml" />
<mapping resource="model/YwYwls.hbm.xml" />
<mapping resource="model/ClGgzxc.hbm.xml" />
<mapping resource="model/ClCz.hbm.xml" />
<mapping resource="model/ClCd.hbm.xml" />
<mapping resource="model/ClCldpmx.hbm.xml" />
<mapping resource="model/ClCdxx.hbm.xml" />
</session-factory>
</hibernate-configuration>
Struts 2.1.8
创建Struts.xml action 中的class 为
<?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/struts-2.1.7.dtd">
<struts>
<!-- 在开发模式下使用,这样可以打印出更详细的错误信息 -->
<constant name="struts.devMode" value="true" />
<package name="bike" namespace="/" extends="struts-default">
<action name="login" class="loginAction">
<result name="index">/main/index.htm</result>
</action>
<action name="clgys" class="clgysAction">
<result name="clgys">/main/gztm/clgys.jsp</result>
<result name="xgclgys">/main/gztm/xgclgys.jsp</result>
<result name="invalid.token">/main/index.htm</result>
</action>
<action name="clgrzxx" class="clGrzxxAction">
<result name="zjclgrzxx">/main/gztm/zjclgrzxx.jsp</result>
<result name="clgrzxx">/main/gztm/clgrzxx.jsp</result>
<result name="clgrmx">/main/gztm/clgrmx.jsp</result>
<!-- token拦截器已经系统定义,所以不用再次定义,一定不能把默认的覆盖掉,也要配上. -->
<!-- token这个Interceptor没有默认配到拦截器栈中 -->
<!--
<interceptor-ref name="token" />
<interceptor-ref name="defaultStack" />
-->
<!-- 重复提交跳转的页面 -->
<!-- 这个拦截器需要有一个返回页面,返回值:固定,struts2给定 -->
<!-- 一般解决重复提交解决办法:1.提交完redirect.2.用这个拦截器 -->
<!-- <result name="invalid.token">/main/index.htm</result>-->
</action>
<action name="xcrz" class="xcrzAction">
<result name="xcrz">/main/gztm/xcrz.jsp</result>
<result name="chezhuang">/main/gztm/chezhuang.jsp</result>
</action>
<action name="clcz" class="clczAction">
<result name="chezhuang">/main/gztm/chezhuang.jsp</result>
</action>
<action name="xxcx" class="xxcxAction">
<result name="xxcx">/main/gztm/xxcx.jsp</result>
<result name="viewCdxx">/main/gztm/viewCdxx.jsp</result>
<result name="viewZxcxx">/main/gztm/viewZxcxx.jsp</result>
</action>
</package>
</struts>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<!--
-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Action 中
ActionContext ac = ActionContext.getContext();
HttpServletRequest request =(HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
分享到:
相关推荐
s2sh整合步骤及配置文件配置s2sh整合步骤及配置文件配置s2sh整合步骤及配置文件配置s2sh整合步骤及配置文件配置
S2SH框架配置步骤,经典的总结,别错过!
s2sh环境配置步骤,做个 记号,但是忘了在来看看。
S2SH的配置文件的配置 S2sH及配置步骤步骤
Struts2.0.14+Spring2.5+Hibernate3.2+Oracle10g+Tomcat6.0开发环境配置,有步骤图示 +web.xml+applicationContext.xml文件配置 还算齐全。。。
经测试成功,愿意与大家共勉,就一分吧,做人要厚道
图解SSH框架配置步骤,自己动手配置S2SH框架
图解SSH框架配置步骤核心提示:现在开发的一个项目使用S2SH框架,配置环境用了一两天,现在把当时配置环境时写的文档整理下发出来,也算加强点记忆。 在本文中,我们将详细讲解SSH框架的配置步骤,包括开发环境的...
开发步骤 2 环境的集成 2 Struts2.1.8所需Jar包 2 Hibernate3.3所需Jar包 3 Spring3.0所需Jar包 3 基于Annotation的Struts配置 5 基于Annotation的Hibernate配置 6 基于Annotation的Spring配置 10 DAO层封装 12 分页...
Struts2 _ Spring2.5 _ Hibernate3.3 三个框架整合文档,内有简单的功能的例子。可以实现一个插入功能。说明文字较少,主要是步骤截图。
1,将S2SH工程导入eclipse,注意这里用的是eclipse 不是myeclipse 2,找到src文件夹下面的 applicationContext.xml 文件,并找到如下代码段 <!-- 配置数据库连接 --> 此时将...
有的用户登录后就长时间空闲,有可能导致安全上的问题,通过打开 /etc/profile 中 TMOUT 注释,将在设置的时间到达后自动logout用户 例如: export TMOUT=120 那么, 用户两分钟没有击键,将自动logout //AIX系统中如何...