Brief Introduction to SSH integration 1. Brief Introduction to SSH integration
1. Configure in web. xml
Struts2 filter <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> added spring context configuration <context-param> <param-name> contextConfigLocation </param-name> <param-value> classpath: applicationContext. xml </param-value> <context-param> adds a listener <listener> <listener-class> org. springframework. web. context. contextLoaderListener </listerner-class> </listener>
2. Configure in applicationContext. xml
ApplicationContext. the data source configuration in xml can be changed to another data source <bean id = "dataSource" class = "org. apache. commons. dbcp. basicDataSource "> property driver <property name =" driverClassName "value =" oracle. jdbc. driver. oracleDriver "/> connection URL <property name =" url "value =" jdbc: oracle: thin :@ localhost: 1521: orcl "/> username <property name =" username "value =" accp "/> password <property name =" password "value =" accp "/> </bean> Configure sessionFactory <bean id = "sessionFactory" class = "org. springframework. orm. hibernate3.LocalSessionFactoryBean "> associated data source <property name =" dataSource "ref =" dataSource "/> Configure the attributes of hibernate <property name =" hibernateProperties "> <props> to connect to the dialect of the database. different data and versions depend on <prop key = "hibernate. dialect "> org. hibernate. dialect. oracle9Dialect </prop> </props> </property> ing file configuration <property name = "mappingResources"> <list> <value> hibernate configuration file path/Class name of the implementation class. hbm. cfg </value> </list> </property> </bean>
3. Configure in struts. xml
After configuring the struts action in applicationContext. xml
In struts. xml, the action class should write the id of the struts action configured in applicationContext. xml.
The above operations may be wrong and configured as needed