Fast Object Database for Java - with JPA/JDO support

Step 6: Set the Spring XML

To integrate the Spring Framework into a web application we have to add the definition of the Spring dispatcher servlet to the web.xml configuration file and to configure that servlet using another xml configuration file.

Open the web.xml file (under Web Pages > WEB-INF) in a text editor (by right clicking and selecting Edit or by double click and then moving to the XML tab in the editor window). Use copy and paste to replace the default content of the web.xml file with the following new content:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns=""

The settings above routes web requests with .html suffix to the Spring dispatcher servlet.

Additional spring configuration is set in another XML file (whose name is derived from the name of the Spring dispatcher servlet in web.xml). To generate that file:

  • Right click the WEB-INF node in the [Projects] window, select New > Other... and then choose the XML category, XML Document and click Next.
  • Enter spring-servlet as the File Name.
  • The Folder should be src\main\webapp\WEB-INF.
  • Click Next and then Finish to create the XML file.

Now use copy and paste to replace the content of the spring-servlet.xml file with the following new content:

<?xml version="1.0" encoding="windows-1252"?>
<beans xmlns=""

  <!-- Use @Component annotations for bean definitions -->
  <context:component-scan base-package="guest"/>

  <!-- Use @Controller annotations for MVC controller definitions -->
  <mvc:annotation-driven />

  <!-- Add JPA support -->
  <bean id="emf" class=
     <property name="loadTimeWeaver">
        <bean class=

  <!-- Add Transaction support -->
  <bean id="myTxManager"
        <property name="entityManagerFactory" ref="emf"/>

  <!-- Use @Transaction annotations for managing transactions -->
  <tx:annotation-driven transaction-manager="myTxManager" />

  <!-- View resolver -->
 <bean class=
   <property name="prefix" value="/WEB-INF/"/>


The settings above guides Spring to support annotations (for components, controllers and transactions), to inject a JPA EntityManager, to manage transactions and to look for JSP pages in the WEB-INF directory.

The next step (and the last in this tutorial) is running the Spring web application.