This repository has been archived by the owner on Aug 5, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch to web.xml based initialization, split web and app contexts
- Loading branch information
Adrian Colyer
committed
Oct 2, 2012
1 parent
e8aba41
commit 9c79147
Showing
5 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/org/springsource/samples/montyhall/config/AppConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.springsource.samples.montyhall.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.ComponentScan.Filter; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.ViewResolver; | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
import org.springframework.web.servlet.view.InternalResourceViewResolver; | ||
|
||
@Configuration | ||
@ComponentScan(basePackages = "org.springsource.samples.montyhall", | ||
excludeFilters = {@Filter(Controller.class)}) | ||
public class AppConfig { | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> | ||
|
||
<!-- Use annotation-based configuration from the montyhall.config package --> | ||
<context-param> | ||
<param-name>contextClass</param-name> | ||
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> | ||
</context-param> | ||
<context-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value>org.springsource.samples.montyhall.config.AppConfig</param-value> | ||
</context-param> | ||
|
||
<!-- Creates the Spring Application Context based on the above --> | ||
<listener> | ||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
</listener> | ||
|
||
<!-- Main servlet --> | ||
<servlet> | ||
<servlet-name>appServlet</servlet-name> | ||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | ||
<init-param> | ||
<param-name>contextClass</param-name> | ||
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>contextConfigLocation</param-name> | ||
<param-value>org.springsource.samples.montyhall.config.WebConfig</param-value> | ||
</init-param> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>appServlet</servlet-name> | ||
<url-pattern>/</url-pattern> | ||
</servlet-mapping> | ||
|
||
<!-- Disables Servlet Container welcome file handling. Needed for compatibility with Servlet 3.0 and Tomcat 7.0 --> | ||
<welcome-file-list> | ||
<welcome-file></welcome-file> | ||
</welcome-file-list> | ||
|
||
</web-app> |