代码之家  ›  专栏  ›  技术社区  ›  Joseph Hwang

bootstrap css文件和jquery js文件没有链接到ef头文件中

  •  0
  • Joseph Hwang  · 技术社区  · 7 年前

    我是一个新兵的春天靴子。下图显示了我的引导css文件和jqueryjs文件在springboot模板上的文件夹位置。

    enter image description here

    <html xmlns:th="http://www.thymeleaf.org"
          xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
    <head>
        <div th:fragment="header-css">
    
            <title>Spring Boot Blog</title>
    
            <script th:src="@{/js/jquery-2.1.4.min.js}"></script>
            <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" />
            <link rel="stylesheet" type="text/css" href="/css/main.css" th:href="@{/css/main.css}" />
    
        </div>
    </head>
    <body>
        <div th:fragment="header">
       .....
    

    但是css和js脚本根本没有链接。 有什么想法吗!

    ==已更新==

    我正在评估 the spring blog example . 我认为我的问题与登录控制器有关。首先这是登录控制器代码。

    @Controller
    public class LoginController {
    
        @GetMapping("/login")
        public String login(Principal principal) {
    
            String username = (principal != null ? principal.getName() : "ANONYMOUS");
    
            if(principal != null) {
                return "redirect:/home";
            }
    
            // ALWAYS PRINTING "ANONYMOUS is WRONG!!!!" 
            System.out.println(username + "  is WRONG!!!!"); 
    
            return "/login";
        }
    }
    

    甚至更多

    return "/login"
    

    行带来错误的文件。在下面登录.html文件,

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
    <head>
        <div th:replace="/fragments/header :: header-css"/>
    </head>
    <body>
    
    <div th:replace="/fragments/header :: header"/>
    
    <div class="container">
    
        <div class="row" style="margin-top:20px">
            <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
                <form th:action="@{/login}" method="post">
                    <fieldset>
    

    <link rel="stylesheet" type="text/css" href="/css/main.css" th:href="@{/css/main.css}" />
    
    0 回复  |  直到 7 年前