亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

SpringBoot不使用模板引擎直接返回Html怎么配置?

SpringBoot不使用模板引擎直接返回Html怎么配置?

慕姐4208626 2018-08-03 17:29:18
SpringBoot不使用模板引擎直接返回Html怎么配置?
查看完整描述

2 回答

?
陪伴而非守候

TA貢獻1757條經驗 獲得超8個贊

在resource目錄下面建立public文件夾,里面方靜態頁面

訪問路徑為/xx.html

在Controller里面直接return "xx.html"


查看完整回答
反對 回復 2018-08-07
?
暮色呼如

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.*都能是正常訪問的。

    }

}


查看完整回答
反對 回復 2018-08-07
  • 2 回答
  • 0 關注
  • 4422 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號