1

I am trying to implement an application which queries data based on a @PathVariable. Slight complexity is that the path variable is at the root. I mean it's like mydomain.com/{myVar}.

When I try to implement something like this, the issue is it's clashing with many resources directly under the root (eg: index.html).

As a part of solving the problem, I tried to serve static resources under root from controller individually(Though it doesn't sound like a proper solution), But, not sure how to send the resources using Spring Controller methods.

Also, I tried to see if there was a way to exclude url-mappings within @RequestMapping, But didn't work.

Is there a way to implement this? What would be the best and efficient practice?

My application currently uses Spring boot with gradle, and static resources are under src/main/webapp Any help is appreciated, Thank you

Vsoma
  • 595
  • 1
  • 5
  • 17
  • `it's clashing with many resources directly under the root (eg: index.html).` Does that give you exception or what happens ? What if the path variable doesn't have any value ? Think thats the case it encounters – Vinay Veluri Mar 14 '16 at 04:23
  • Yes, It makes application not load. Its because, resource request for **index.html** is also captured within the same request (**myVar value is 'index.html'**), and I am not sure how to handle that request properly. – Vsoma Mar 14 '16 at 12:09
  • The first conflict I faced is with **index.html**, I don't think I encountered a case where path variable doesn't have a value within that request (But, I believe that it was a separate request which triggered the **index.html** resource request). – Vsoma Mar 14 '16 at 12:37
  • This thread should help you : [http://stackoverflow.com/questions/16332092/spring-mvc-pathvariable-with-dot-is-getting-truncated](http://stackoverflow.com/questions/16332092/spring-mvc-pathvariable-with-dot-is-getting-truncated) – Ilalaina Mar 15 '16 at 08:35
  • That thread is totally different, I don't have a problem of variable getting truncated. I am dealing with /{myVar} type path variable. – Vsoma Mar 16 '16 at 10:51

0 Answers0