0

I am trying to run a single page web application and map all URLs to index html. I have a non-rest controller which looks like this:

@RequestMapping(value = "/*")
public String getIndex()
{
    return "index";
}

and this works fine. However, it does not match further forward slashes in the URL. Moreover, if I change the request mapping value from /* to /**, I start getting stack overflow exceptions: https://drive.google.com/file/d/0B83g4hczCyxgUDZDWTM5R1NLemM/view?usp=sharing.

Does anybody know how I can use @RequestMapping(value = "/**") without getting stack overflow exceptions?

UPDATE

In jetty it gives the following error:

javax.servlet.ServletException: Circular view path [/WEB-INF/index.html]: would dispatch back to the current handler URL [/WEB-INF/index.html] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.).

Full stack trace here

The interesting thing about this message is that it knows that "index" refers to the file "/WEB-INF/index.html". Why can't it just render this view if it knows about it?

I have also found another stackoverflow.com question with the same problem. It was asked a year ago and still doesn't have an answer. Furthermore, this used to work in previous versions of Spring.

james
  • 1,035
  • 2
  • 14
  • 33
  • Can you add the lines after: 2017-07-15 22:47:13.815 ERROR 4437 --- [nio-8090-exec-1] o.a.c.c.C.[.[.[.5.0.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] threw exception – Ivan Lynch Jul 15 '17 at 23:40
  • Does the problem still occur if you switch to [Jetty](http://docs.spring.io/spring-boot/docs/1.5.4.RELEASE/reference/htmlsingle/#howto-use-jetty-instead-of-tomcat) or [Undertow](http://docs.spring.io/spring-boot/docs/1.5.4.RELEASE/reference/htmlsingle/#howto-use-undertow-instead-of-tomcat)? – Andy Wilkinson Jul 16 '17 at 06:39
  • @AndyWilkinson by switching to jetty I get the following error: javax.servlet.ServletException: Circular view path [/WEB-INF/index.html]: would dispatch back to the current handler URL [/WEB-INF/index.html] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) – james Jul 16 '17 at 08:17
  • Interesting, thanks. Can you provide a minimal example that reproduces the problem? There are too many unknowns based on what you've described thus far – Andy Wilkinson Jul 16 '17 at 08:38
  • Also, judging by your initial description of the problem, the solution you are attempting to use isn't quite right. IMO, this is a better approach: https://stackoverflow.com/questions/40769200/configure-spring-boot-for-spa-frontend – Andy Wilkinson Jul 16 '17 at 08:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/149315/discussion-between-james-and-andy-wilkinson). – james Jul 16 '17 at 09:27

0 Answers0