2 回答

TA貢獻1757條經驗 獲得超8個贊
在resource目錄下面建立public文件夾,里面方靜態頁面
訪問路徑為/xx.html
在Controller里面直接return "xx.html"

TA貢獻1853條經驗 獲得超9個贊
@Configuration
public class MvcConfigurer extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/home").setViewName("home.html");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
super.configurePathMatch(configurer);
configurer.setUseSuffixPatternMatch(false);//當此參數設置為true的時候,那么/user.html,/user.aa,/user.*都能是正常訪問的。
}
}
- 2 回答
- 0 關注
- 4422 瀏覽
添加回答
舉報