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; }
