Saturday, May 9, 2009

Spring PropertyPlaceholderConfigurer

Here is the code to use PropertyPlaceholderConfigurer with XMLBeanFactory

XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("test.xml"));
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(new ClassPathResource("jdbc.properties"));
// now actually do the replacement
cfg.postProcessBeanFactory(factory);
MyBean bean = (MyBean)factory.getBean("myBean");
System.out.println(bean .getProperty());

Thursday, May 7, 2009

Struts common configurations

<!-- Standard Action Servlet Configuration (with debugging) -->

<servlet>

<servlet-name>action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

<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>

<load-on-startup>2</load-on-startup>

</servlet>