最近的項目中採用的是RESTful Web Service技術,後端不需要生成動態網頁。這裏有兩個需要注意的點:
1. 項目靜態文件目錄如下圖所示
2. 不要在build.gradle中引入thymeleaf依賴。因爲引入該依賴後,spring boot默認的view resolver就是thymeleaf了。原本默認的是InternalResourceViewResolver,默認路徑“classpath:static”
3.添加如下類進行配置
@Configuration
public class MvcConfigurer extends WebMvcConfigurerAdapter {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
super.configurePathMatch(configurer);
configurer.setUseSuffixPatternMatch(false);
}
}
否則會出現“Circular view path” exception。當然,如果你的URL和返回的view名稱不一樣,則不用配置。