Align MustacheViewResolver with other similar resolvers

The `FreeMarkerViewResolver` (and other template-based resolvers) in
Spring Framework avoid using reflection if they know how to
instantiate the view class. This change aligns with them.

See gh-24011
This commit is contained in:
Dave Syer 2020-11-03 14:15:47 +00:00 committed by Andy Wilkinson
parent 699f03d5a6
commit 22693c17f3
1 changed files with 5 additions and 0 deletions

View File

@ -75,4 +75,9 @@ public class MustacheViewResolver extends AbstractTemplateViewResolver {
return view;
}
@Override
protected AbstractUrlBasedView instantiateView() {
return (getViewClass() == MustacheView.class ? new MustacheView() : super.instantiateView());
}
}