1

I am having trouble getting my url-mapping correct.

My Controller looks like this...

@Controller
@RequestMapping(value = "/rest/report")
public class ReportController extends CatalogManagementBaseController { 
...
@RequestMapping(method = RequestMethod.GET) 
public @ResponseBody String test(Model model) throws Exception{
    return "Worked!";
}
}

And my url-mapping looks like this..`

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>`

If I change the url mapping to / it works but I want the dispatcher to only handle the requests sent to ../rest/...

Any idea what I am doing wrong? Could it be something to do with the inheritance?

2 Answers 2

3

If you want the dispatcher to be mapped to /rest/* then I believe you should remove this prefix from the controller's @RequestMapping, i.e. only have RequestMapping(/report).

The mapping you have configured would result in the Controller listening to requests on /rest/rest/report

Sign up to request clarification or add additional context in comments.

Comments

3

If your servlet is mapped to /rest/* then the controller should be annotated with:

@RequestMapping(value = "/report")

1 Comment

I will have to try this, I solved it by using just / and it hasn't effected the static content yet but I will try this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.