On Jun 12, 2013, at 11:32 PM, Eran Medan <ehrann.mehdan_at_gmail.com> wrote:
> Dear Fellow JAX-RS users!
>
> I'm trying to use JAX-RS as an MVC router, (to replace the need for Spring's @RequestMapping)
>
> To do so, I would like to have my JAX-RX Application start at the root context, so my URLs will be
>
> http://example.com/restfullPath
>
> and not:
>
> http://example.com/rest/restfullPath
>
> I switched my Application's annotation from this
>
> @ApplicationPath("/rest/*")
> to this
>
> @ApplicationPath("/*")
FWIW, the "*" should not be specified in the application path. It is implicit.
> All works well, but then it seems that it takes over serving files such as /index.html or /index.jsp
>
> Is there a way to run a JAX-RS on the root context but still have static / JSP pages served?
There is not a standard solution. Concrete frameworks implement static content filter support. Alternatively, you can implement your own one by registering a Servlet filter that will do this for you.
Marek
>
> Seems this was asked before on the JBOSS forum, but the solution is not really practical
>
> (I asked this originally here: http://stackoverflow.com/questions/10874188/jax-rs-application-on-the-root-context-how-can-it-be-done but the answer is too cumbersome and negates the benefit of using JAX-RS with it's simplicity and elegant API)
>
> The reason I'm asking is that this moved me back to Spring, which I rather work without
> In Spring @RequestMapping("/foo") works as well as @RequestMapping("/foo/bar") and is absolute to the web app context, and can serve JSP / HTML views without a problem.
>
> In other words, I would expect to be able to map any request in JEE to any resource, whether it's a JSON service, or a JSP view using the same easy to use @Path annotation, can it be done?
>
> Thanks,
> Eran
>
>