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

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

慕姐4208626
浏览 4276回答 2
2回答

陪伴而非守候

在resource目录下面建立public文件夹,里面方静态页面访问路径为/xx.html在Controller里面直接return "xx.html"

暮色呼如

@Configurationpublic 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.*都能是正常访问的。    }}
打开App,查看更多内容
随时随地看视频慕课网APP