The reason this is happening is that you are sending all JSP
files through the dispatcher
. The dispatcher
then finds the RequestMapping
attribute on the PageContoller
and lets it try to handle the request.
This means that when Spring MVC requests a View, instead of being allowed to load the View, it is treated like a webpage. The PageController
tries to resolve it from Tridion, instead of allowing the ViewResolver
to load it from the file-system.
Instead, do the following:In order of execution:
- You request
/index.jsp
, which is handled by thePageController
PageController
(and subsequent method calls) determine the Page Template required is/WEB-INF/views/homepage.jsp
/WEB-INF/views/homepage.jsp
is requested, as the associated Page Template, which is also (mistakenly) handled by thePageController
due to greedy regex- Request for
/WEB-INF/views/homepage.jsp
returns a 404 as no such Page is published from Tridion
Instead, do the following:
In web.xml before your dispatcher servlet-mapping
add the following, to send View requests to the View folder(s)
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>/WEB-INF/views/*</url-pattern>
</servlet-mapping>
On your PageController specify the RequestMapping to handle the extensions you need
@RequestMapping(value = { "/**/*.jsp", "/**/*.html", "/**/*.txt", "/**/*.xml" }, method = { GET })