hi all,
i have a very basic strut use case
myjsp ---> TestAction --> some other
jsp.
In my
test action i want to use hibernateDaoSupport. i just did the exact whats there in the petclinic appliction. here is the detailed code and also the configuration i did
In my TestAction.java Code
HibernateClinic cl = new HibernateClinic();
Collection col = cl.getVets();
return mapping.findForward(str);
HibernateClinic.java
public class HibernateClinic extends HibernateDaoSupport {
public Collection getVets() throws DataAccessException {
return getHibernateTemplate().find("from Vet vet order by vet.lastName, vet.firstName");
}
}
My big issue is how to make
struts recogize to load spring application context for this in my web.xml i did the following
My web.xml file is the same as any other and it is left untouched
<
servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResource</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
i haven't changed anything here
but in struts-config.xml
i did the following according to this tutorial at IBM
http://www-128.ibm.com/developerworks/java/library/j-sr2.html <struts-config>
<form-beans>
</form-beans>
<action-mappings>
<action
path="/Test"
type="com.action.TestAction"
input="/test.jsp">
<forward name="index" path="/test.jsp"/>
</action>
</action-mappings>
<message-resources parameter="ApplicationResources" />
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"/>
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext-hibernate.xml"/>
</plug-in>
Please note how i am configuring my applicationContext-hibernate.xml file in teh contextConfigLocation property. The thing i need to know is how to hook up these application context in my struts applicaiton. i haven't changed anything in the applicationContext-hibernate.xml.
If anyone could please let me know how to approach this considering my naive expertise level in dealing with this
Thanks
Rashid