Autogenerated logical view name through RequestToViewNameTranslator

In this section, you will learn about handling the situation where view name is not provided, through RequestToViewNameTranslator interface.

Autogenerated logical view name through RequestToViewNameTranslator

In this section, you will learn about handling the situation where view name
is not provided, through RequestToViewNameTranslator interface.

Where no view name is provided, the RequestToViewNameTranslator
interface determines the view name automatically. For this you need to configure
DefaultRequestToViewNameTranslator class in Spring MVC configuration
file.

Note that no view name is provided in the above code. For auto generation of
the view name, you need to configure the
DefaultRequestToViewNameTranslator class in Spring MVC configuration
file as shown below :

In the above controller code, you can see that no view name is provided. The
DefaultRequestToViewNameTranslator class, configured in conjunction
with ControllerClassNameHandlerMapping , is responsible for auto
generating view name.

In the above case, if the requested URL is :

http://localhost/writing.html

the resultant generated logical view name would be writing
.According to above configuration and returned view name the resultant view name
would be reside in " /WEB-INF/jsp/ " as writing.jsp.