Spring Boot MVC

yml配置模板:

 thymeleaf:
    cache: false
    prefix: classpath:/templates/
    suffix: .html
    encoding: UTF-8
    mode: HTML
    servlet:
      content-type: text/html

自动配置扩展

@Configuration
//@EnableWebMvc 覆盖默认配置加此标签
public class CustomWebMvcConfigurer implements WebMvcConfigurer{

}

静态资源默认路径:static public resources

欢迎界面:resources/static/index.html

webjars jquery:
grade引入

    compile group: 'org.webjars', name: 'webjars-locator-core', version: '0.35'
    compile group: 'org.webjars', name: 'jquery', version: '3.3.1-1'

html引入:

<script type="application/javascript" src="/webjars/jquery/3.3.1-1/jquery.min.js"></script>

view Controller:

@Controller
@RequestMapping("/user/")
public class ViewController {
    @RequestMapping("/userList")
    public String index(){
        return "list";
    }
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容