zoukankan      html  css  js  c++  java
  • springboot+thymeleaf模版通过ctroller层访问页面引入js css失效

    @RestController
    @RequestMapping("dsd")
    public class DataController extends BaseController {
        @RequestMapping("toindex")
        public ModelAndView toindex(Model model){
           /*  model.addAttribute("moudels",dataService.index());
             model.addAttribute("question",dataService.question());
             model.addAttribute("information",dataService.information());
             model.addAttribute("rank",dataService.indexRank());*/
            return new ModelAndView("index");
        }

    如果是以为加上了它所以访问不到static下的资源了,这是应为你用themleaf引入css和js时的路径写错了,应该在你写的路径前加上/

      <link  th:href="@{/css/index.css}" rel="stylesheet">
        <link rel="stylesheet" th:href="@{/css/header.css}">
        <link rel="shortcut icon" th:href="@{/images/login.ico}" type="image/x-icon">
        <link rel="stylesheet" th:href="@{/font-awesome-4.7.0/css/font-awesome.min.css}">  

      这样加上后,就会发现页面的css,js能引入了

  • 相关阅读:
    最少必要知识
    pythonGUI编程
    计算机网络基础
    .htaccess总结
    SSRF总结
    jsp学习笔记
    url任意跳转漏洞
    学期总结
    计科一班本学期作业成绩汇总表格
    C语言I博客作业08
  • 原文地址:https://www.cnblogs.com/wkyhky/p/9358252.html
Copyright © 2011-2022 走看看