Announcement Announcement Module
No announcement yet.
getting requestparam from part of the url with annotations Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting requestparam from part of the url with annotations

    We are trying to use the Controller, RequestMapping and RequestParam annotations on a multi-action controller.

    What we want is to have a method that responds to a url like /customer/123. This method would go off and do something with a customer with an id of 123 in our system.

    In order to do this, we need to pass in the value '123' into the method.

    The expectation we had would be that we could do this with something like the following:

    public class Customer{
    	<at>RequestMapping(value = "/customer/(:id)", method = RequestMethod.GET)
    	public void getCustomer(<at>RequestParam("id") String id) {
    		//do something with id
    However, this isn't working for us - id is left unassigned.

    We have seen how to get the parameters from the url, but getting parts of the url assigned to a variable deosn't seem to work. This is something we used to do in Rails quite often and were hoping it would be possible with SpringMVC as well. Is there a way to do this?

    We're using spring-webmvc-2.5.3.