Skip to content

RC2: Issue with RequestMethod.GET differs from M2 [SPR-6378] #11045

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 89975c8

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions