I am trying to figure out how i am building a restFull Web server that will:
1: Serve a single index.html file when going to /
2: all other URLs will get caught by the controllers in a restful manner for example: /invoke1 -> will reach the request mapping of "/invoke1"
The problem:
First of all spring dispatcher has some weird fallout with serving html pages (i am not talking about resources and the <mvc:resources mapping
) i am talking about serving an html page and not JSP.
i solved this issue by using the default catalina servlet like so:
<servlet> <servlet-name>default</servlet-name> <servlet-class> org.apache.catalina.servlets.DefaultServlet </servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/docs/*</url-pattern> </servlet-mapping>
With this code i can serve HTML pages (Even behind security, as long as they are under the /docs/* path), So from here i can do:
@RequestMapping(method = RequestMethod.GET) public String main() { return "redirect:/docs/index.html"; }
But that's not what i want. from here on out the URL on the browser will be displayed as /docs/
What i want to happen is that when the user goes to / he will get the index.html but when he goes to /invoke1 he will reach the spring controller.
This is something i am trying to figure out for some time now. hope you can guide me to the right solution. Thank you.