Skip to main content
added 512 characters in body
Source Link
Chris Morgan
  • 7.3k
  • 17
  • 32

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:

  1. You request /index.jsp, which is handled by the PageController
  2. PageController (and subsequent method calls) determine the Page Template required is /WEB-INF/views/homepage.jsp
  3. /WEB-INF/views/homepage.jsp is requested, as the associated Page Template, which is also (mistakenly) handled by the PageController due to greedy regex
  4. 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 })

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 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 })

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.

In order of execution:

  1. You request /index.jsp, which is handled by the PageController
  2. PageController (and subsequent method calls) determine the Page Template required is /WEB-INF/views/homepage.jsp
  3. /WEB-INF/views/homepage.jsp is requested, as the associated Page Template, which is also (mistakenly) handled by the PageController due to greedy regex
  4. 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 })
Source Link
Chris Morgan
  • 7.3k
  • 17
  • 32

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 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 })