【问题标题】:Using ViewAccessControl in Spring and Vaadin在 Spring 和 Vaadin 中使用 ViewAccessControl
【发布时间】:2016-08-13 12:32:04
【问题描述】:

我目前正在尝试使用 vaadin.spring 的 ViewAccessControl 接口,如this 教程的最后一段中所述。

但是在实现 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();
}

附:这家伙一年前遇到的问题基本相同:How to create a secure view with Vaadin and SpringViewProvider

【问题讨论】:

    标签: spring spring-security spring-boot vaadin vaadin4spring


    【解决方案1】:

    好的,我现在想通了。如果其他人发现这个问题,解决方案是使用 ViewInstanceAccessControl 接口而不是 ViewAccessControl 接口。这样一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多