Spring,实例变量在新线程中的可见性从@PostConstruct开始

问题描述在下面的情况下,Spring是否保证‘sleepInterval’和‘BusinessLogic’实例变量的可见性?importorg.springframework.beans.factory.annotation.Value;importorg.springframe

发布:2022-10-16 标签:javavisibilityconcurrencyspringpostconstruct


即使 ManagedBean 已经被实例化(例如在 AJAX 调用上),@PostConstruct 方法也会被调用

问题描述我有一个@ViewScopeManagedBean和一个@PostConstruct初始化方法.创建新实例时会调用此方法,但也会在每次ajax调用时调用.为什么会这样?在AJAX调用中,init-Method被调用并执行,但没有任何变化可见.例如,如果我更改了init-M

发布:2022-10-16 标签:ajaxjsfjsf-2view-scopepostconstruct


JSF bean:在设置 ViewParam 后调用 @PostConstruct 函数

问题描述我有一个product.xhtml和一个ProductBean.我使用/product/{id}来访问产品,所以我在product.xhtml中有一个viewParam值=ProductBean.id.问题是在bean内部我使用了一个带有PostConstruct注释的i

发布:2022-10-16 标签:jsf-2postconstructmanaged-beanviewparams


@PostConstruct 方法为同一个请求调用两次

问题描述我使用JSF2.0和GlassFish3.0.I'musingJSF2.0withGlassFish3.0.我有以下托管Bean:IhavethefollowingManagedBean:@ManagedBean@RequestScopedpublicclassOverv

发布:2022-10-16 标签:javajsfjsf-2postconstruct


@PostConstruct &检查异常

问题描述在@PostConstruct文档中它说注释方法:Inthe@PostConstructdocitsaysabouttheannotatedmethods:该方法不得抛出已检查的异常."人们将如何处理例如可以在这种方法中抛出的IOException?只是将它包装在一个Ru

发布:2022-10-16 标签:javaexception-handlingjakarta-eepostconstruct


即使 bean 是 @ViewScoped,为什么每次都会触发 @PostConstruct 回调?JSF

问题描述我在页面上使用数据表并使用绑定属性将其绑定到我的支持bean.这是我的代码:-Iamusingdatatableonpageandusingbindingattributetobindittomybackingbean.Thisismycode:-<?xmlversion

发布:2022-10-16 标签:jsffaceletsview-scopepostconstruct


如何在页面加载期间添加 FacesMessage?使用@PostConstruct 似乎不起作用

问题描述在支持bean的@PostConstruct方法中,我调用了一个EJB,它可能会返回一些我想通过p:messages在页面上显示的消息.但是,即使我添加了FacesMessages,例如FacesContext.getCurrentInstance().addMessag

发布:2022-10-16 标签:pageloadjsfmessagepostconstruct


何时使用 f:viewAction/preRenderView 与 PostConstruct?

问题描述与使用@PostConstruct注释相比,什么时候应该使用f:viewAction或preRenderView事件来初始化页面的数据?使用一种或另一种的基本原理是基于支持bean的范围类型,例如如果支持bean是@RequestScoped,那么会选择使用f:viewA

发布:2022-10-16 标签:jsfjsf-2postconstructprerenderviewviewaction


Spring AOP 和后构造

问题描述我想写下与@PostConstruct一起使用的方法的名称.但是我发现AOP无法绕过"PostConstruct方法.有没有什么方法可以将AOP与PostConstruct方法一起使用?Iwanttowritethenameofmethodwhichisusingwith

发布:2022-10-16 标签:aopspringspring-mvcaspectjpostconstruct


使用 Spring @Lazy 和 @PostConstruct 注解

问题描述我有以下课程:@RepositoryclassA{publicvoidmethod1(){...}}@ComponentclassBimplementsC{@Autowired@LazyprivateAa;publicvoidmethod2(){a.method1();}

发布:2022-10-16 标签:javalazy-evaluationspringannotationspostconstruct