properties文件使用{0}...

例如properties文件的配置

weixin.token.url=https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}

java文件中可以写成:

/**
* 微信Token请求接口地址
*/
@Value("${weixin.token.url}")
private String tokenUrl;

String address = MessageFormat.format(tokenUrl, appId, secret);

MessageFormat类来拼接

posted @ 2016-12-14 15:25  ding9587  阅读(684)  评论(0编辑  收藏  举报