Subject: Spring MVC -- Configuration
Author: WebSpider
In response to: Spring MVC -- Flow
Posted on: 11/23/2017 02:31:39 AM
/WEB-INF/web.xml
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/*.xml</param-value>
</context-param>
<!-- LISTENERS -->
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- FILTERS -->
<!-- Creates the filters shared by all Servlets and Filters -->
<!-- ... -->
<!-- SERVLETS -->
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/myServlet/dispatch-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
dispatch-servlet.xml
<!-- Resolves views selected for rendering by @Controller -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- bean injection by constructor
<constructor-arg></constructor-arg>
-->
<!-- bean injection by setter -->
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- Auto-detection for annotation @Controllers -->
<context:component-scan base-package="com.xyz.springmvc" />
<context:component-scan base-package="com.xyz.springmvc2" />
>
> On 11/23/2017 02:29:23 AM
WebSpider wrote:
+-----------+
| View | /WEB-INF/views/
+-----------+ +-----------+
| Filters | |
+-----------+ |
| |
| +------------+ +-----------+
client ----> DispatcherServlet ---> | Controller |------------| Model | /app/models/
+------------+ +-----------+
/WEB-INF/web.xml @Controller |
@RequestMapping |
------
| DB |
------
References: