Skip to content

BeanNameViewResolver should not try to use non-View beans [SPR-12079] #16695

@spring-projects-issues

Description

@spring-projects-issues

Oliver Drotbohm opened SPR-12079 and commented

To resolve a view, BeanNameViewResolver checks for the presence of a bean with the view name and then looks it up using context.getBean(name, View.class).

This throws an exception if the view name is the name of an arbitrary Spring bean by accident, which is not a View. I suggest to look up the bean instance without the type constraint and only return it if it really implements View. Alternatively, the BeanNotOfRequiredTypeException could be caught and handled by returning null.


Affects: 3.2.10, 4.0.6, 4.1 RC1

Referenced from: commits 42c090e, 626a5fe, 035a9b9, 92bd240

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions