Spring學習筆記系列(五) 與hibernate整合 a
<?xml version="1.0" encoding="UTF-8"?> <beans> <!-- ========================= RESOURCE DEFINITIONS ========================= --> <!-- Local Apache Commons DBCP DataSource that refers to a combined database --> |
原來包含很多復雜內容的applicationContext.xml也拷貝一份applicationContext2.xml,刪除和JPetStore相關的內容,留下通用的部分:
<?xml version="1.0" encoding="UTF-8"?> <!-- <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <!-- |
在Struts配置文件中增加自己的Action如下:
<action path="/showusers" type="srx.test.struts.action.UserAction"> <forward name="success" path="/WEB-INF/jsp/srx/test/hibernate/showusers.jsp"/> </action> |
web.xml中使用action作為*。do處理的servlet而不是默認的petstore。
并注釋掉名字為petstore,remoting的servlet。如下:
<web-app 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" version="2.4">
<display-name>Spring JPetStore</display-name>
<description>Spring JPetStore sample application</description>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>petstore.root</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dataAccessContext-hibernate.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
...
</web-app>
posted on 2007-06-18 18:01 chenguo 閱讀(176) 評論(0) 編輯 收藏 所屬分類: Spring Dev