如何使用Vaadin和SpringViewProvider创建安全视图 [英] How to create a secure view with Vaadin and SpringViewProvider

查看:137
本文介绍了如何使用Vaadin和SpringViewProvider创建安全视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关于Vaadin的教程 III - 视图和导航Vaadin Spring

There is a tutorial about Vaadin III - Views and Navigation with Vaadin Spring

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

If I want to use Apache Shiro. How should I use 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定义一个范围代理,如果你打算从一个单例引用它;嵌套异常是java.lang.IllegalStateException:没有活动视图

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securedView': 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

推荐答案

问题是你正在尝试将bean注入狭隘的背景。
,例如SpringUI:UIScope => SpringView:ViewScope
尝试查看内部注释,它们已经携带SpringComponent
干杯

The problem is that you're trying to inject the bean in a narrow context. e.g. SpringUI : UIScope => SpringView : ViewScope Try to have a look "inside" annotation, they carry already the SpringComponent Cheers

这篇关于如何使用Vaadin和SpringViewProvider创建安全视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆