Description
Ken Sipe opened SPR-6378 and commented
I have a demo for Spring 3 Web that I've been running for some time... the upgrade to RC2 broke the demo. The code is listed below. What we need is details on the order of requestmappings... I thought I saw that earlier this year in the forums, but I can't find it anymore. Can someone please provide the details on the order of requestmappings... thanks.
The code below (which worked before) now fails for a GET request against the list method or http://localhost:8080/mvc/book/list
I had specified the GET and POST for clarification before on the create methods... after some investigation, I discovered that if I remove the method = RequestMethod.GET on the create method that the app begins to work. So I can work around this. What behavior should be expected?
@Controller
public class BookController {
@Autowired
BookDAO dao;
// http://localhost:8080/mvc/book/list
@RequestMapping("list")
public List<Book> list() {
return dao.findAllBooks();
}
// http://localhost:8080/mvc/book/book?id=12
@RequestMapping("book")
public Book book(@RequestParam(required = true) Long id) {
Book book = dao.getBook(id);
return book;
}
@RequestMapping(method = RequestMethod.GET)
public Book create() {
return new Book();
}
// http://localhost:8080/mvc/book/create (POST)
@RequestMapping(method = RequestMethod.POST)
public String create(@ModelAttribute Book book, BindingResult results) {
if (book == null)
return null;
dao.save(book);
return "redirect:list";
}
}
Affects: 3.0 RC2
Issue Links:
- Combining ControllerClassNameHandlerMapping and @RequestMapping with relative value on Controller method doesn't work anymore [SPR-6475] #11141 Combining ControllerClassNameHandlerMapping and
@RequestMapping
with relative value on Controller method doesn't work anymore ("is duplicated by")
Referenced from: commits 89975c8