我目前正在尝试使用本教程最后一段中解释的 vaadin.spring 的 ViewAccessControl 接口。
但是在实现 isAccessGranted 方法时,我收到以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'frontPageView': Scope 'vaadin-view' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No active view
FrontPageView 类的声明(我在 enter 方法中唯一做的就是添加一些 vaadin ui 元素):
@SpringView(name = FrontPageView.NAME)
public class FrontPageView extends DashboardDesign implements View, ViewAccessControl {
@Override
public void enter(ViewChangeEvent event) {
}
}
我对 isAccessGranted 方法的实现:
@Override
public boolean isAccessGranted(UI ui, String beanName) {
return SecurityContextHolder.getContext().getAuthentication().isAuthenticated();
}
PS 这基本上是这个家伙一年前遇到的问题:How to create a secure view with Vaadin and SpringViewProvider