当我第一次访问我的页面时,页面使用的托管bean是instanciate两次(我在构造器中传递了两次,具有相同的堆栈跟踪):JSF - 托管bean的两个实例
Daemon Thread [http-127.0.0.1-8080-1] (Suspended (breakpoint at line 76 in MyController))
MyController.<init>() line: 76
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor<T>.newInstance(Object...) line: 513
Class<T>.newInstance0() line: 355
Class<T>.newInstance() line: 308
ManagedBeanBuilder(BeanBuilder).newBeanInstance() line: 186
...
pass throught two Filters (one of the filter uses Waffle and the other calls a web service...)
...
Http11Protocol$Http11ConnectionHandler.process(Socket) line: 601
JIoEndpoint$Worker.run() line: 447
Thread.run() line: 662
在XHTML:
<a4j:keepAlive beanName="myController"></a4j:keepAlive>
<h:form>
...
</h:form>
在faces-config.xml中:
<managed-bean>
<managed-bean-name>myController</managed-bean-name>
<managed-bean-class>com.xx.MyController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
为什么托管bean我s instanciate两次?
感谢您的想法...
使用
- JSF 1.2
- RichFaces的3.3.2.SR1
编辑: 感谢Joeri亨德里克斯,我发现我有两个不同的要求。所以新的问题是“为什么当我访问我的页面时有两个请求?”
由于您的bean是请求范围的,所以不应该如此。你说你有两次相同的堆栈跟踪;检查Request对象是否相同。 –
你说得对,其实这不是同一个要求。指示:在此过程中,我通过两个过滤器(其中一个过滤器使用Waffle,另一个过滤器调用Web服务...)。 –
@Joeri:你应该重新发布这个答案,它实际上是两个物理上不同的请求。 – BalusC