静态资源在本地主机上正常,在远程服务器上找不到

时间:2017-05-26 14:21:25

标签: spring-boot openshift thymeleaf

我的春季启动应用程序,其中一些静态资源通过百日咳提供服务如下

主管部分

<!DOCTYPE html>

<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
        <meta charset="utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <title>Home | Connect In</title>

    <!-- Vendor CSS -->
        <link th:href="@{/vendors/bower_components/animate.css/animate.min.css}" rel="stylesheet"/>
        <link th:href="@{/vendors/bower_components/sweetalert/dist/sweetalert.css}" rel="stylesheet"/>
        <link th:href="@{/vendors/bower_components/material-design-iconic-font/dist/css/material-design-iconic-font.min.css}"
              rel="stylesheet"/>
        <link th:href="@{/vendors/bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css}" rel="stylesheet"/>
        <link th:href="@{/vendors/bower_components/lightgallery/dist/css/lightgallery.min.css}" rel="stylesheet"/>

        <!-- CSS -->
        <link th:href="@{/css/app_1.min.css}" rel="stylesheet"/>
        <link th:href="@{/css/app_2.min.css}" rel="stylesheet"/>
    </head>

在页面末尾

<!-- Javascript Libraries -->
        <script th:src="@{/vendors/bower_components/jquery/dist/jquery.min.js}" type="text/javascript"></script>
        <script th:src="@{/vendors/bower_components/bootstrap/dist/js/bootstrap.min.js}" type="text/javascript"></script>

        <script th:src="@{/vendors/bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js}" type="text/javascript"></script>
        <script th:src="@{/vendors/bower_components/Waves/dist/waves.min.js}" type="text/javascript"></script>
        <script th:src="@{/vendors/bootstrap-growl/bootstrap-growl.min.js}" type="text/javascript"></script>
        <script th:src="@{/vendors/bower_components/sweetalert/dist/sweetalert.min.js}" type="text/javascript"></script>
        <script th:src="@{/vendors/bower_components/lightgallery/dist/js/lightgallery-all.min.js}" type="text/javascript"></script>
        <script th:src="@{/vendors/bower_components/autosize/dist/autosize.min.js}" type="text/javascript"></script>

        <!-- Placeholder for IE9 -->
        <!--[if IE 9 ]>
            <script th:src="@{/vendors/bower_components/jquery-placeholder/jquery.placeholder.min.js}" type="text/javascript"></script>
        <![endif]-->

        <script th:src="@{/js/app.min.js}" type="text/javascript"></script>

此应用在本地主机服务器环境中运行良好,意味着所有资源都得到了很好的服务,但是当我在openshift上部署应用时,我会收到错误,可以在此代码段中看到

GET not found 404 error

我不知道如何解决这个问题,强烈欢迎任何建议和建议。

1 个答案:

答案 0 :(得分:0)

通过使用 cdn 解决了问题,您可以更改

主管部分

<!-- Vendor CSS -->
        <link th:href="@{https://bowercdn.net/c/animate.css-3.5.2/animate.min.css}" rel="stylesheet"/>
        <link th:href="@{https://bowercdn.net/c/sweetalert-1.1.2/dist/sweetalert.css}" rel="stylesheet"/>
        <link th:href="@{https://bowercdn.net/c/material-design-iconic-font-2.2.0/dist/css/material-design-iconic-font.css}"
              rel="stylesheet"/>
        <link th:href="@{https://bowercdn.net/c/malihu-custom-scrollbar-plugin-3.1.5/jquery.mCustomScrollbar.min.css}" rel="stylesheet"/>
        <link th:href="@{https://bowercdn.net/c/lightgallery-1.3.9/dist/css/lightgallery.min.css}" rel="stylesheet"/>

在结束部分

<!-- Javascript Libraries -->
        <script th:src="@{https://bowercdn.net/c/jquery-3.2.1/dist/jquery.min.js}" type="text/javascript"></script>
        <script th:src="@{https://bowercdn.net/c/bootstrap-3.3.7/dist/js/bootstrap.min.js}" type="text/javascript"></script>

        <script th:src="@{https://bowercdn.net/c/malihu-custom-scrollbar-plugin-3.1.5/jquery.mCustomScrollbar.concat.min.js}" type="text/javascript"></script>
        <script th:src="@{https://bowercdn.net/c/waves-0.7.5/dist/waves.min.js}" type="text/javascript"></script>
        <script th:src="@{https://cdnjs.cloudflare.com/ajax/libs/bootstrap-growl/1.0.6/bootstrap-growl.min.js}" type="text/javascript"></script>
        <script th:src="@{https://bowercdn.net/c/sweetalert-1.0.1/dist/sweetalert.min.js}" type="text/javascript"></script>
        <script th:src="@{https://bowercdn.net/c/lightgallery-1.3.9/dist/js/lightgallery.min.js}" type="text/javascript"></script>
        <script th:src="@{https://bowercdn.net/c/autosize-3.0.21/dist/autosize.min.js}" type="text/javascript"></script>

因此问题得以解决......

谢谢。