Jumper
Jumper

Reputation: 133

RequestMapping doesn't redirect

 @RequestMapping(value = "/{Id}",  method = RequestMethod.GET)
        public String searchCity( @PathVariable ("Id") Long Id) {
         mymethod.something(id);
          return "successpage";
        }

When I'm trying to write some number it print me Eror 404 resource is not available, but when I write {Id} ("7DId7D" smthing like this) it redirects me to succespage, What is the problem? Help me please...

Upvotes: 0

Views: 160

Answers (1)

gerrytan
gerrytan

Reputation: 41143

The information you provided conflicts with known behavior of Spring MVC

  • http://localhost:8080/MyCountryProject/7 should maps to searchCity fine
  • http://localhost:8080/MyCountryProject/%7Bld%7D should not even map to searchCity

I would check following to further isolate the problem:

  • Are you sure you're testing against the right controller? If your controller has @RequestMapping("myController") then your URL would be http://localhost:8080/MyCountryProject/MyController/7
  • Are you sure you're posting with the correct HTTP method? If you're HTTP form is POST, it wouldn't map to searchCity method
  • The conversion from string into Long is done by Spring MVC builtin property editor, did you install your own property editor? If so debug this

Upvotes: 2

Related Questions