Skip to content

AnnotationMethodHandlerAdapter should take into account request accept header ordering [SPR-6934] #11599

@spring-projects-issues

Description

@spring-projects-issues

Mike Youngstrom opened SPR-6934 and commented

I have a controller like so:

public class ExampleController {
	@RequestMapping(value="/secure/example", headers="accept=text/html",method=RequestMethod.GET)
	public String list(@ModelAttribute ExampleModel example, Model model) {
            ...
	}

	@RequestMapping(value="/secure/example", headers={"accept=application/xml"}, method=RequestMethod.GET)
	public List<ExampleModel> listXml() {
            ...
	}
}

If I submit a request with accept=application/xml,text/html

I would expect that my listXml() method would be resolved before list(). However, because list() is declared first in the class it ends up being the one chosen by AnnotationMethodHandlerAdapter.

It appears that RequestMappingInfoComparator doesn't take into account the order of the accept media types on the request. I believe it should.


Affects: 3.0.1

Referenced from: commits 4f4f3fa

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