wills
Aug 31st, 2004, 12:00 AM
I am now building a web application with OpenSessionInViewFilter, the following is my web.xml :
<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
/WEB-INF/src/dataAccessContext.xml
/WEB-INF/src/contentContext.xml
/WEB-INF/src/scheduleContext.xml
/WEB-INF/src/securityContext.xml
</param-value>
</context-param>
<filter>
<filter-name>Character Encoding</filter-name>
<filter-class>com.raykey.web.filters.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GB2312</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Character Encoding</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter>
<filter-name>HibernateSpringFilter</filter-name>
<filter-class>org.springframework.orm.hibernate.support.OpenSess ionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HibernateSpringFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner </listener-class>
</listener>
And I reference the bean in my Java file using the following way:
ApplicationContext ctx;
String[] paths = {"dataAccessContext.xml",
"contentContext.xml",
"scheduleContext.xml",
"securityContext.xml"};
ctx = new ClassPathXmlApplicationContext(paths);
return ctx.getBean(name);
I want to know whether I am right! If I am wrong , please tell me what to do to let me access the beans in Strtuts Actions, thanks very much!
BTW, if I am right, but why I will got two sessionFactory in one application, when I acess the OpenSessionInViewFilter, I can get a SessionFactory, but when I access the real DAOIMPL, it will use another sessionFactory, so the Session will be not find! Can anybody help me?
<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
/WEB-INF/src/dataAccessContext.xml
/WEB-INF/src/contentContext.xml
/WEB-INF/src/scheduleContext.xml
/WEB-INF/src/securityContext.xml
</param-value>
</context-param>
<filter>
<filter-name>Character Encoding</filter-name>
<filter-class>com.raykey.web.filters.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GB2312</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Character Encoding</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter>
<filter-name>HibernateSpringFilter</filter-name>
<filter-class>org.springframework.orm.hibernate.support.OpenSess ionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HibernateSpringFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner </listener-class>
</listener>
And I reference the bean in my Java file using the following way:
ApplicationContext ctx;
String[] paths = {"dataAccessContext.xml",
"contentContext.xml",
"scheduleContext.xml",
"securityContext.xml"};
ctx = new ClassPathXmlApplicationContext(paths);
return ctx.getBean(name);
I want to know whether I am right! If I am wrong , please tell me what to do to let me access the beans in Strtuts Actions, thanks very much!
BTW, if I am right, but why I will got two sessionFactory in one application, when I acess the OpenSessionInViewFilter, I can get a SessionFactory, but when I access the real DAOIMPL, it will use another sessionFactory, so the Session will be not find! Can anybody help me?