1.properties内容:
check.statisticsRegiona=四川省
2.config配置
@Component
@PropertySource("classpath:check.properties")
@ConfigurationProperties(prefix="check")
public class CheckConfig {
private String statisticsRegiona;
public String getStatisticsRegiona() throws UnsupportedEncodingException {
return changeEncoding(statisticsRegiona);
}
public void setStatisticsRegiona(String statisticsRegiona) {
this.statisticsRegiona = statisticsRegiona;
}
/**
* 将string的encoding改成UTF-8,解决中文乱码
* @param str
* @return
* @throws UnsupportedEncodingException
*/
private String changeEncoding(String str) throws UnsupportedEncodingException {
return new String(str.getBytes("ISO-8859-1"),"UTF-8");
}
}
3.获取信息实体类
@Autowired
private CheckConfig checkConfig;
/*
*