Geomajas Community Documentation

11.1. web.xml

In your web.xml file, you need to assure the configuration is made available to the application, and you can indicate which files are used to contain the configuration. Though it is possible to put all configuration information in one file, we recommend splitting your configuration in several files. At least one file per application, possibly split further per client layer configuration, and one file for server-side configuration of each of the layers.

The listener class initialises the application context as needed for Geomajas. It appends the context configuration locations which are specified in the contextConfigLocation context parameter to the list of internal configuration locations and uses these to build the application context. When no location is specified, the files is searched on the class path. You can also use location prefixes as defined by Spring. To allow use of configuration file on the web context, use an empty location (just a colon as prefix, eg ":/WEB-INF/config.xml"). Note that whitespace is used as separator which means that the path itself should not contain spaces.

These are defined using an excepts like the following:

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            org/geomajas/dojo/simple/*.xml
        </param-value>
    </context-param>

    <listener>
         <listener-class>org.geomajas.servlet.GeomajasContextListener</listener-class>
    </listener>

Example 11.1. Defining spring configuration locations in web.xml


You also need to define at least the dispatcher servlet and possible an additional servlet for your faces. The dispatcher servlet can be defined as follows.

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:META-INF/geomajasWebContext.xml</param-value>
        <description>Spring Web-MVC specific (additional) context files.</description>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/d/*</url-pattern>
</servlet-mapping>

Example 11.2. Dispatcher servlet declaration in web.xml