Special Bean Types of WebApplicationContext

Special Bean Types of WebApplicationContext

Special Bean Types of WebApplicationContext

Special Bean Types of WebApplicationContext

In this section, you will learn about Special Bean Types in the WebApplicationContext.

In Spring , special bean types are needed by DispatcherServlet to process the http requests and render the suitable view back to the client. You can configure one or more beans according to your need in the WebApplicationContext. Default beans list is retained by the Spring MVC, in case if it is not configured. This list is kept inside the package org.springframework.web.servlet as file DispatcherServlet.properties.

You can configure special bean type as given below (Here bean type is viewResolver):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

	<context:component-scan base-package="net.roseindia.controller" />

	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.UrlBasedViewResolver">
		<property name="viewClass"
		value="org.springframework.web.servlet.view.JstlView" />
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>
</beans>

Complete list of beans type in WebApplicationContext is given below :

Bean Type

Details

HandlerMapping According to some criteria this bean maps oncoming requests to handlers and handler interceptors.
HandlerAdapter Irrespective of the handler is really called, it helps the DispatcherServlet to called a handler mapped to a request.
HandlerExceptionResolver This bean maps exceptions to views and also permitting complex exception handling.
ViewResolver This bean actually resolves view names ,provided as string ,into actual view types.
LocaleResolver This bean resolves the locale of the client.
ThemeResolver This bean resolves the themes which can be utilized by your application.
MultipartResolver This bean parses multi-part requests. For example, file uploading using HTML forms.
FlashMapManager  The input and the output FlashMap is stores and retrieves by this bean to pass on attributes from one request to another generally around a redirect.