Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以在一个spring应用程序中使用两个不同的tiles-def.xml,其中一个将根据条件选择吗_Spring - Fatal编程技术网

我可以在一个spring应用程序中使用两个不同的tiles-def.xml,其中一个将根据条件选择吗

我可以在一个spring应用程序中使用两个不同的tiles-def.xml,其中一个将根据条件选择吗,spring,Spring,我有两个tiles-def,例如tiles-def1.xml和tiles-def2.xml 是否可以使用某种条件选择一个tile def文件?例如,类似于: if (true) { choose tiles-def1.xml } else { choose tiles-def2.xml } 您可以根据应用程序运行的环境(如果是您的用例),将定义文件的路径作为外部属性(到SpringJava或xml配置)提供。Java配置示例: @Configuration @PropertyS

我有两个tiles-def,例如
tiles-def1.xml
tiles-def2.xml

是否可以使用某种条件选择一个tile def文件?例如,类似于:

if (true) {
    choose tiles-def1.xml
} else {
    choose tiles-def2.xml
}

您可以根据应用程序运行的环境(如果是您的用例),将定义文件的路径作为外部属性(到SpringJava或xml配置)提供。Java配置示例:

@Configuration
@PropertySource("classpath:/path/to/properties/app.properties")
public class Application {

    @Autowired Environment environment;

    @Bean
    public TilesConfigurer tilesConfigurer() {
       TilesConfigurer tilesConfigurer = new TilesConfigurer();
       tilesConfigurer.setDefinitions(environment.getProperty("pathToTilesFile"));
       return tilesConfigurer;
   }
   ....
}

如果它不是您的解决方案,请提供有关您的用例的更多详细信息。

什么条件决定了选择哪个文件?