1

I have been reading on Spring 3.2 lately and I am now trying the following code using Spring 2.5. From what I have read this should mean that it should map profile/tags/me. However it doesn't. It just throws a No mapping found for HTTP request with URI .... What is wrong with the code, or didn't Spring 2.5 work like it does in Spring 3?

Problem when using Spring 2.5

@Controller
@RequestMapping("/profile/tags")
public class ProfileController { ... }

And this is the method inside ProfileController class:

@RequestMapping(value = "/me", method = RequestMethod.GET)    
public String show(@RequestParam final long id, final ModelMap model) { ... }
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434

1 Answers1

4

According to Spring documentation, I imagine you're missing the required configuration to receive the request parameter, if you mean to receive this request parameter:

@RequestMapping(value = "/me/{id}", method = RequestMethod.GET)    
public String show(@RequestParam("id") final long id, final ModelMap model) { ... }

Or you should remove RequestParam.

Update for Spring 2.5

Additionally, since you're using Spring 2.5, make sure that you've configured your DispatcherServlet in the expected way; Sections 13.11, subsections 1, 2, and 3. In summary:

  1. DispatcherServlet should be told to load annotated RequestMappings.
  2. DispatcherServlet should be told to load Controller annotations.
  3. Not sure but maybe you need to refine the paths you use for the request mappings.

Hope this helps.

nobeh
  • 9,784
  • 10
  • 49
  • 66
  • This is the link that I create: `Me`, I did not manage to get it work with your answer. – LuckyLuke Apr 08 '13 at 10:40
  • The format `?id=${id}` is "QueryParam". To have it as a "RequestParam", you should use `.../tags/me/${id}`. – nobeh Apr 08 '13 at 10:43
  • Can you also try [this](http://stackoverflow.com/a/6970128/248082) to verify your link is as expected? Or directly go to `http://yourserver/yourapp/profile/tags/me/SOMEID`? – nobeh Apr 08 '13 at 10:57
  • Updated the answer. I tried to read the differences in more detail, I hope this helps. – nobeh Apr 08 '13 at 11:24
  • This is strange. I got the necassary beans etc that is mentioned. And the RequestMapping annotations on the methods work for specifying the method such as GET, POST. But the value is not recognized it seems. At least not in together with requestmapping on the class level. – LuckyLuke Apr 08 '13 at 11:34