Allow ContentNegotiatingViewResolver to be strict ant return a 406 if no view found [SPR-6467] #11133
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Oliver Drotbohm opened SPR-6467 and commented
Currently
ContentNegotiatingViewResolver
acts lenient as it returnsnull
when it can not resolve any view to indicate that furtherViewResolvers
configured shall step in and try to resolve the view.In cases when
ContentNegotiatingViewResolver
is the only resolver configured, not resolving the view should be answered with a406 Not Acceptable
status code. A quick hack I did was to add a propertybeStrict
toCNVR
an implement an inner class to return the appropriate statuscode. See applied patch.This solves the problem at a first glance but I think it would be more clean to prevent processing of the request entirely if no valid accept header was set by using the algorithm
getmediaTypes(..)
inCNVR
. Currently this method is not public, but I could imagine aHandlerInterceptor
implementation that gets a reference to theCNVR
injected and call togetMediaType(..)
to decide whether to process the request at all.Affects: 3.0 RC2
Attachments:
Issue Links:
Referenced from: commits 1cd0a97
The text was updated successfully, but these errors were encountered: