/ Published in: XML
Basic web.xml setup for using Spring MVC, Sitemesh, and Hibernate (using hibernate filter for lazy loading)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?xml version="1.0" encoding="UTF-8"?> <web-app id="BioSafetyWebApp" 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>Archetype Created Web Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/yourApplicationNameHere-context.xml /WEB-INF/yourApplicationNameHere-servlet.xml /WEB-INF/yourApplicationNameHere-persistence.xml /WEB-INF/yourApplicationNameHere-security.xml /WEB-INF/yourApplicationNameHere-service.xml </param-value> </context-param> <servlet> <servlet-name>yourApplicationNameHere</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>yourApplicationNameHere</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <filter> <filter-name>sitemesh</filter-name> <filter-class> com.opensymphony.module.sitemesh.filter.PageFilter </filter-class> </filter> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Allows me to lazy load objects --> <filter> <filter-name>hibernateFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> </filter> <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Usually just does a jsp forward to a default action --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- Commented out during development, it's easier to just see the app server blow up <error-page> <error-code>404</error-code> <location>/404.jsp</location> </error-page> <error-page> <exception-type>java.lang.Exception</exception-type> <location>/error.jsp</location> </error-page> --> </web-app>