当我第一次访问我的页面时,页面使用的托管 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 实例化两次?
谢谢你的想法...
使用
- jsf 1.2
- 富脸3.3.2.SR1
编辑:感谢Joeri Hendrickx,我发现我有两个不同的请求。所以新的问题是“为什么我在访问我的页面时有两个请求?”