赞
踩
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-text</artifactId>
- <version>1.8</version>
- </dependency>
- String phoneNo = "13812341234";
- String smsTemplate = "验证码:#{[code]},您正在登录管理后台,5分钟内输入有效。";
- Map<String, Object> params = new HashMap<>();
- params.put("code", 1234);;
-
- ExpressionParser parser = new SpelExpressionParser();
- TemplateParserContext parserContext = new TemplateParserContext();
- String content = parser.parseExpression(smsTemplate,parserContext).getValue(params, String.class);
-
- System.out.println(content);
使用场景如:各种短信验证码模板等
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。