@Viewscope在bean中没有使用@Scope(value = BeanDefinition.SCOPE_PROTOTYPE)?

时间:2017-06-20 12:59:49

标签: spring spring-mvc jsf

我有一个用

注释的控制器

@Component(value = "somevalue") @ViewScoped一切正常,但我有一个单独的lazyModel类,所以用@Scope(value=org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE)

注释

后来我开始知道@Autowire将为每个请求提供相同的类,所以我们需要从上下文获取类是我的控制器...`@Component(value =" someValue")

@ViewScoped
public class ACAppUserController extends AbsController {

    @Autowired
    private SomeLazyModel lazyModel;

    public SomeLazyModel getLazyModel() {
        this.lazyModel = (SomeLazyModel) context.getBean("SomeLazyModel");
        return lazyModel;
    }

    public void setLazyModel(ACAppUserLazyModel lazyModel) {
        this.lazyModel = lazyModel;
    }

} 

这是我的SomeLazyModel,它有userModel ...

@Component(value = "SomeLazyModel")
@Scope(value=org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE)
public class SomeLazyModel extends AbsSomeLazyModelLazyModel<UserModel> {

    private static final long serialVersionUID = 1L;
    private static final Logger logger = Logger
            .getLogger(SomeLazyModel.class);


    private UserModel user;

Usermodel有用户名,密码变量......

  

所以我的问题是当我提交表单用户名和密码为空时   的usermodel ...

所以在从上下文获取someLazyModel之前一切正常......

请帮忙...

0 个答案:

没有答案