|
Spring Framework example source code file (web.xml)
The Spring Framework web.xml source code<?xml version="1.0" encoding="ISO-8859-1"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Spring PetClinic <description>Spring PetClinic sample application <!-- Key of the system property that should specify the root directory of this web app. Applied by WebAppRootListener or Log4jConfigListener. --> <context-param> <param-name>webAppRootKey <param-value>petclinic.root </context-param> <!-- Location of the Log4J config file, for initialization and refresh checks. Applied by Log4jConfigListener. --> <context-param> <param-name>log4jConfigLocation <param-value>/WEB-INF/log4j.properties </context-param> <!-- - Location of the XML file that defines the root application context. - Applied by ContextLoaderServlet. - - Can be set to: - "/WEB-INF/applicationContext-hibernate.xml" for the Hibernate implementation, - "/WEB-INF/applicationContext-jpa.xml" for the JPA one, or - "/WEB-INF/applicationContext-jdbc.xml" for the JDBC one. --> <context-param> <param-name>contextConfigLocation <param-value>/WEB-INF/applicationContext-jdbc.xml <!-- <param-value>/WEB-INF/applicationContext-hibernate.xml <param-value>/WEB-INF/applicationContext-jpa.xml --> <!-- To use the JPA variant above, you will need to enable Spring load-time weaving in your server environment. See PetClinic's readme and/or Spring's JPA documentation for information on how to do this. --> </context-param> <!-- - Configures Log4J for this web app. - As this context specifies a context-param "log4jConfigLocation", its file path - is used to load the Log4J configuration, including periodic refresh checks. - - Would fall back to default Log4J initialization (non-refreshing) if no special - context-params are given. - - Exports a "web app root key", i.e. a system property that specifies the root - directory of this web app, for usage in log file paths. - This web app specifies "petclinic.root" (see log4j.properties file). --> <!-- Leave the listener commented-out if using JBoss --> <!-- <listener> <listener-class>org.springframework.web.util.Log4jConfigListener </listener> --> <!-- - Loads the root application context of this web app at startup, - by default from "/WEB-INF/applicationContext.xml". - Note that you need to fall back to Spring's ContextLoaderServlet for - J2EE servers that do not follow the Servlet 2.4 initialization order. - - Use WebApplicationContextUtils.getWebApplicationContext(servletContext) - to access it anywhere in the web application, outside of the framework. - - The root context is the parent of all servlet-specific contexts. - This means that its beans are automatically available in these child contexts, - both for getBean(name) calls and (external) bean references. --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener> <!-- - Servlet that dispatches request to registered handlers (Controller implementations). - Has its own application context, by default defined in "{servlet-name}-servlet.xml", - i.e. "petclinic-servlet.xml". - - A web app can contain any number of such servlets. - Note that this web app has a shared root application context, serving as parent - of all DispatcherServlet contexts. --> <servlet> <servlet-name>petclinic <servlet-class>org.springframework.web.servlet.DispatcherServlet <load-on-startup>2 </servlet> <!-- - Maps the petclinic dispatcher to "*.do". All handler mappings in - petclinic-servlet.xml will by default be applied to this subpath. - If a mapping isn't a /* subpath, the handler mappings are considered - relative to the web app root. - - NOTE: A single dispatcher can be mapped to multiple paths, like any servlet. --> <servlet-mapping> <servlet-name>petclinic <url-pattern>*.do </servlet-mapping> <session-config> <session-timeout>10 </session-config> <welcome-file-list> <!-- Redirects to "welcome.htm" for dispatcher handling --> <welcome-file>index.jsp </welcome-file-list> <error-page> <exception-type>java.lang.Exception <!-- Displays a stack trace --> <location>/WEB-INF/jsp/uncaughtException.jsp </error-page> <!-- - Reference to PetClinic database. - Only needed if not using a local DataSource but a JNDI one instead. --> <!-- <resource-ref> <res-ref-name>jdbc/petclinic <res-type>javax.sql.DataSource <res-auth>Container </resource-ref> --> </web-app> Other Spring Framework examples (source code examples)Here is a short list of links related to this Spring Framework web.xml source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.