Spring Thymeleaf Bootstrap CSS

后端 未结 2 458
谎友^
谎友^ 2021-02-13 13:14

I\'m trying to use Bootstrap CSS with my Spring + Security + Thymeleaf web application. The CSS gets picked up the by my custom login screen and everything is fine - all styles

相关标签:
2条回答
  • 2021-02-13 13:31

    Figured it out ... schoolboy error on my part ...

    The following link in my home.html file wasn't resolving to the right location:

    <link href="resources/css/bootstrap-3.3.2-dist/bootstrap.min.css" rel="stylesheet" />
    

    So instead, I used context-relative URL as follows:

    <link th:href="@{/resources/css/bootstrap-3.3.2-dist/bootstrap.min.css}" rel="stylesheet" />
    

    And this did the trick.

    0 讨论(0)
  • 2021-02-13 13:35

    You code should have worked even without the Spring Expression @{}. Just include the javascript part of bootstrap which is included download zip file.

    <link rel="stylesheet" href="/bootstrap-4.0.0/css/bootstrap.min.css" />
    <script src="/bootstrap-4.0.0/js/bootstrap.min.js"></script>
    

    bootstrap-4.0.0 is located in src/main/resources/static/

    0 讨论(0)
提交回复
热议问题