Apache Tiles是否有类似Struts的devMove,它会在每次请求时重新加载tiles.xml文件?如果是这样,如何启用它?
答案 0 :(得分:3)
这是另一个使用Listener而不是Filter的工作配置。 (自Tiles 2.1.2起)
在web.xml中:
<context-param>
<param-name>org.apache.tiles.definition.dao.LocaleUrlDefinitionDAO.CHECK_REFRESH</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.tiles.web.startup.TilesListener</listener-class>
</listener>
答案 1 :(得分:1)
我使用过瓷砖,但从未试图动态重新加载它。
但是,此页面:http://tiles.apache.org/tutorial/configuration.html
表示:
Load the Tiles filter. It is useful if your definition files can be changed and you periodically need to reload them.
答案 2 :(得分:0)
以下在servlet容器中使用tile 2.2.2对我有用。
....
import org.apache.tiles.definition.DefinitionsFactory;
import org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory;
import org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO;
import org.apache.tiles.impl.BasicTilesContainer;
import org.apache.tiles.servlet.context.ServletUtil;
//When using SimpleTilesListener => BasicTilesContainer is returned
//When using StrutsTilesListener => CachingTilesContainer is returned which extends BasicTilesContainer
BasicTilesContainer tilesCont = (BasicTilesContainer) ServletUtil.getContainer(ServletActionContext.getServletContext());
DefinitionsFactory defFact = tilesCont.getDefinitionsFactory();
Field field= UnresolvingLocaleDefinitionsFactory.class.getDeclaredField("definitionDao");
field.setAccessible(true);
ResolvingLocaleUrlDefinitionDAO rludDAO = (ResolvingLocaleUrlDefinitionDAO)field.get(defFact);
rludDAO.refresh();