Spring feature toggle 示例

很少用Java作为技术栈的我,很少有Java的笔记,记录一下这个简单的feature toggle。

Spring PropertyPlaceHolder

Stackflow 上有一个关于这个问题的回答。

1.使用bean创建一个properties。(mvc-config.xml)

<util:properties id="myProps" location="WEB-INF/config/prop.properties"/>

2.注入值

@Value("#{myProps['message']}")

这样就可以在root contextmvc context下工作

3.在jsp中使用

<spring:eval expression="@myProps.message" var="messageToggle"/>

<c:if test="${messageToggle eq true}">
    message
</c:if>

4.在测试中使用

messageToggles = ResourceBundle.getBundle("myProps");

或许您还需要下面的文章:

关于我

Github: @phodal     微博:@phodal     知乎:@phodal    

微信公众号(Phodal)

围观我的Github Idea墙, 也许,你会遇到心仪的项目

QQ技术交流群: 321689806