ServerMonkey
ServerMonkey

Reputation: 1154

Spring REST Service - Set the Root URI

New to spring and have a question regarding setting the Rest URI path.

I have a working rest service and I would like to change the URI from something like http://localhost:8080/myapp/api to http://localhost:8080/api

Normally I would do this with an annotation such as: @ApplicationPath("api") but that doesnt seem to be applicable, tried the below but doesnt give the desired result.

TestController.java

@Controller
@RequestMapping("api")
public class TestController {
    @RequestMapping("/test")
    public @ResponseBody Test Test() {
        return new Test("Test String");
    }
}

How can this be done with spring?

Upvotes: 0

Views: 933

Answers (1)

Russell Shingleton
Russell Shingleton

Reputation: 3196

Generally configured in META-INF/context.XML. Set path to / or "".

Here's a similar issue with tomcat 7

HOWTO set the context path of a web application in Tomcat 7.0

Upvotes: 1

Related Questions