それは疑問の余地があります(struts 2 Beanは作成されません)私はTomcatの下の非常に単純なWebアプリケーションでstruts2+トップリンクを使用しています。このページでは、反復タグを使用したいと思います。そのため、エンティティのコレクション(Entity)を解決するファクトリ(SomeFactory)を宣言しました。記事ごと:http ://download-uk.oracle.com/docs/cd/B32110_01/web.1013/b28221/usclient005.htm#CIHCEHHG 必要なのは宣言だけです:
@PersistenceContext(unitName="name_in_persistence_xml")
public class SomeFactory
{
@PersistenceUnit(unitName="name_in_persistence_xml")
EntityManagerFactory emf;
public EntityManager getEntityManager() {
assert(emf != null); //HERE every time it is null
return emf.createEntityManager();
}
public Collection<Entity> getAll()
{
return getEntityManager().createNamedQuery("Entity.findAll").getResultList();
}
}
なにが問題ですか?web.xmlで何かを見逃している可能性がありますか?インジェクションを許可するためにWebアプリケーションのトップリンクを事前に初期化する方法は?