Skip to content

HEAD/GET in MVC not fully backward-compatible [SPR-14383] #18956

@spring-projects-issues

Description

@spring-projects-issues

Francisco Lozano opened SPR-14383 and commented

I have a controller that looks more or less like this (just relevant parts):

@RequestMapping("/abcd/{myID}/stuff")
public class StuffController extends AbstractBaseController {
	/* ... */
	@ResponseBody
	@ResponseStatus(value = HttpStatus.NO_CONTENT)
	@RequestMapping(value = "/*", method = HEAD)
	public void checkExists(@PathVariable MyID myID) throws StuffNotFoundException {
		stuffService.checkExists(myID, parsePath());
	}


	@ResponseBody
	@RequestMapping(value = "/*", method = GET, produces = StuffRetrievalResponse.JSON_MIME_TYPE)
	public StuffRetrievalResponse get(@PathVariable MyID myID) throws StuffNotFoundException {
		Stuff stuff = stuffService.get(myID, parsePath());
		StuffRetrievalResponse res = new StuffRetrievalResponse();
		fill(res, stuff);
		return res;
	}

}

Now, always GET gets invoked instead of HEAD. We are still debugging but we're thinking that the compareTo method in RequestMethodsRequestCondition is related to the issue.


Affects: 4.3 GA

Referenced from: commits 058279b

1 votes, 3 watchers

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