Bootstrap文件未加载

时间:2016-07-15 08:21:14

标签: jquery twitter-bootstrap spring-mvc

My bootstrap folder structure in eclipse 我使用spring mvc,如果我在web.xml中执行调度程序servlet配置,则bootstrap文件没有加载到浏览器,否则如果引导程序css的CDN一切正常,为什么本地文件没有在eclipse中加载

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
                pageEncoding="ISO-8859-1"%>
            <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
            <html>
            <head>
                <meta charset="utf-8">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width, initial-scale=1">
                <meta name="description" content="">
                <meta name="author" content="">
                <title>Login Page</title>
                <!-- Bootstrap Core CSS -->
                 <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> 
                     <!-- MetisMenu CSS -->
                 <link href="bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet"> 
                <!-- Custom CSS -->
                 <link href="dist/css/sb-admin-2.css" rel="stylesheet"> 
                <!-- Custom Fonts -->
                 <link href="bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
                 <link rel="stylesheet" href="Mine/css/MyCss.css"></link>    
              <script type="text/javascript" src="vendor/jquery/jquery.min.js"></script>

            </head>
            <body>
                <div class="container">
                    <div class="row">
                        <div class="col-md-4 col-md-offset-4">
                            <div class="login-panel panel panel-default">
                                <div class="panel-heading">
                                    <h3 class="panel-title">Please Sign In Here</h3>
                                </div>
                                <div class="panel-body">
                                    <form id="loginForm" role="form" action="login" method="post">
                                        <fieldset>
                                            <div class="form-group">
                                            <div class=" col-xs-15 control-label">
                                                <input class="form-control" placeholder="E-mail or Username" name="userName" type="text" autofocus>
                                            </div>
                                             </div>
                                            <div class="form-group">
                                             <div class=" col-xs-15 control-label">
                                                <input class="form-control" placeholder="Password" name="password" type="password" value="">
                                            </div>
                                            </div>
                                            <div class="checkbox">
                                                <label>
                                                    <input name="remember" type="checkbox" value="Remember Me">Remember Me
                                                </label>
                                            </div>
                                             <input type="submit" class="btn btn-lg btn-success btn-block" value="login" /> 
                                       <br>

                                       <div class="dropdown">
                                        <button class="btn btn-info dropdown-toggle" type="button" data-toggle="dropdown">Registration Yourself
                                             <span class="caret"></span></button>
                                                <ul class="dropdown-menu">
                                                    <li><a href="pages/StudentEnrollmentFromAdmin.jsp">Student</a></li>
                                                    <li><a href="ParentsByAdmin.jsp">Parent</a></li>
                                                    <li><a href="TeacherByAdmin.jsp">Teacher</a></li>
                                               </ul>
                                            &nbsp<span><u><a href="#">Forgot your password ?</a></u></span>
                                        </div>
                                     </fieldset>

                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- jQuery -->

                <script src="Mine/scripts/loginscript.js"></script>
                <script src="bower_components/jquery/dist/jquery.min.js"></script>
                <!-- Bootstrap Core JavaScript -->
                <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
                <!-- Metis Menu Plugin JavaScript -->
                <script src="bower_components/metisMenu/dist/metisMenu.min.js"></script>
                <!-- Custom Theme JavaScript -->
                <script src="dist/js/sb-admin-2.js"></script>
                <script type="text/javascript"  src="dist/js/bootstrapValidator.js"></script>
            </body>
            </html>


            <servlet>
                    <servlet-name>mvc</servlet-name>
                    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                    <init-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value>/WEB-INF/spring-config.xml
                    </param-value>
                    </init-param>
                    <load-on-startup>1</load-on-startup>
                </servlet>
                <servlet-mapping>
                    <servlet-name>mvc</servlet-name>
                    <url-pattern>/</url-pattern>
                </servlet-mapping> 

1 个答案:

答案 0 :(得分:0)

我们必须将所有静态引导程序内容放在资源文件夹

示例Webcontent / resources / Bootstrap文件

然后在springContext.xml

中配置以下行
<mvc:resources mapping="/resources/**" location="/resources/" />

    <mvc:annotation-driven />