jiefu

1、在application.properties中自定义参数

spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=root

spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
#开发时关闭缓存,不然没法看到实时页面
spring.thymeleaf.cache=false

name=cppdy

2、在UserController中获取自定义参数,并创建测试方法

//获取自定义参数的值
@Value("${name}")
private String name;
//测试获取自定义参数值的方法
@RequestMapping("getName")
public String getName() {
    return name;
}

 

分类:

技术点:

相关文章:

  • 2021-11-23
  • 2021-11-23
  • 2021-10-28
  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
猜你喜欢
  • 2021-11-23
  • 2017-12-12
  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
  • 2021-12-03
相关资源
相似解决方案