Commit 180c094c by fsn

把beetl配置放到java配置里

parent a4eee8a7
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>com.stylefeng</groupId> <groupId>com.stylefeng</groupId>
<artifactId>guns</artifactId> <artifactId>guns</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>war</packaging>
<name>guns</name> <name>guns</name>
<description>guns 的spring boot版本</description> <description>guns 的spring boot版本</description>
......
package com.stylefeng.guns.config.properties;
import java.util.Properties;
/**
* beetl配置
*
* @author fengshuonan
* @date 2017-05-22 18:45
*/
public class BeetlProperties {
private static BeetlProperties beetlProperties = new BeetlProperties();
private Properties properties = new Properties();
private BeetlProperties(){
init();
}
public void init() {
//开始结束占位符
this.properties.setProperty("DELIMITER_PLACEHOLDER_START", "${");
this.properties.setProperty("DELIMITER_PLACEHOLDER_END", "}");
//开始结束标签
this.properties.setProperty("DELIMITER_STATEMENT_START", "@");
this.properties.setProperty("DELIMITER_STATEMENT_END", "null");
//classpath 根路径
this.properties.setProperty("RESOURCE.root", "/WEB-INF/view");
//是否检测文件变化
this.properties.setProperty("RESOURCE.autoCheck", "true");
//beetl HTMl标签
this.properties.setProperty("HTML_TAG_FLAG", "#");
//自定义标签文件Root目录和后缀
this.properties.setProperty("RESOURCE.tagRoot", "common/tags");
this.properties.setProperty("RESOURCE.tagSuffix", "tag");
}
public static Properties newInstance(){
return beetlProperties.properties;
}
}
package com.stylefeng.guns.config.web; package com.stylefeng.guns.config.web;
import com.alibaba.druid.support.http.StatViewServlet; import com.alibaba.druid.support.http.StatViewServlet;
import com.stylefeng.guns.config.properties.BeetlProperties;
import com.stylefeng.guns.core.beetl.BeetlConfiguration; import com.stylefeng.guns.core.beetl.BeetlConfiguration;
import com.stylefeng.guns.core.listener.ConfigListener; import com.stylefeng.guns.core.listener.ConfigListener;
import com.stylefeng.guns.core.util.xss.XssFilter; import com.stylefeng.guns.core.util.xss.XssFilter;
...@@ -10,7 +11,6 @@ import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; ...@@ -10,7 +11,6 @@ import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.context.request.RequestContextListener; import org.springframework.web.context.request.RequestContextListener;
/** /**
...@@ -28,7 +28,7 @@ public class WebConfig { ...@@ -28,7 +28,7 @@ public class WebConfig {
@Bean(initMethod = "init") @Bean(initMethod = "init")
public BeetlConfiguration beetlConfiguration() { public BeetlConfiguration beetlConfiguration() {
BeetlConfiguration beetlConfiguration = new BeetlConfiguration(); BeetlConfiguration beetlConfiguration = new BeetlConfiguration();
beetlConfiguration.setConfigFileResource(new ClassPathResource("beetl.properties")); beetlConfiguration.setConfigProperties(BeetlProperties.newInstance());
return beetlConfiguration; return beetlConfiguration;
} }
......
#开始结束占位符
DELIMITER_PLACEHOLDER_START=${
DELIMITER_PLACEHOLDER_END=}
#开始结束标签
DELIMITER_STATEMENT_START=@
DELIMITER_STATEMENT_END=null
#classpath 根路径
RESOURCE.root=/WEB-INF/view
#是否检测文件变化
RESOURCE.autoCheck=true
#beetl HTMl标签
HTML_TAG_FLAG=#
#自定义标签文件Root目录和后缀
RESOURCE.tagRoot=common/tags
RESOURCE.tagSuffix=tag
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment