如何使用Vaadin和SpringViewProvider创建安全视图

有一个关于Vaadin III的教程- 使用Vaadin Spring进行视图和导航

如果我想使用Apache Shiro。 我应该如何使用ViewAccessControl?

@SpringComponent @SpringView(name = SecuredView.VIEW_NAME) public class SecuredView extends VerticalLayout implements View, ViewAccessControl { public static final String VIEW_NAME = "view"; @PostConstruct void init() { addComponent(new Label("This is a secured view scoped view")); } @Override public boolean isAccessGranted(UI ui, String string) { return true; } } 

我得到了例外:

org.springframework.beans.factory.BeanCreationException:创建名为’securedView’的bean时出错:Scope’vaadin-view’对当前线程无效; 考虑为这个bean定义一个范围代理,如果你打算从一个单例引用它; 嵌套exception是java.lang.IllegalStateException:没有活动视图

问题是你试图在狭窄的环境中注入bean。 例如SpringUI:UIScope => SpringView:ViewScope试着看一下“内部”注释,它们已经带有SpringComponent干杯