一个JSP文件找到CSS外部文件,而另一个JSP文件找不到CSS文件

时间:2018-08-09 21:12:54

标签: html css jsp

嗯,我一直在从事J2EE项目。但是我的项目表现得很奇怪。我将spring配置为处理静态资源。

 @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("/static/");
        
    }

我尝试从My home.jsp访问CSS文件,并且工作正常。但是,当我想从另一个jsp文件registration.jsp访问另一个css文件stylerg.css时,它不起作用! ???相同的项目具有相同的结构,但css文件表现出混乱。也让我发疯这是home.jsp的代码

<%-- 
    Document   : home
    Created on : Aug 7, 2018, 4:37:50 PM
    Author     : Noman Ibrahim
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="f" %>

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@taglib uri="http://www.springframework.org/tags" prefix="s" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="static/css/styleHome.css">
          
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        
        <title>HOME || Doctor's House</title>
    </head>
    <body>

        <div class="navbar">
            <div class="navbar__header">
                <img src="static/images/doctorlogo.jpg" alt="medical center" class="navbar__logo" >
                <div class="navbar__btn">
                    <div class="bar bar1"></div> 
                    <div class="bar bar2"></div>
                    <div class="bar bar3"></div>
                </div>
            </div>
            <ul class="navbar_link">
                <s:url var="url_log" value="student/loginPage"></s:url>
                <s:url var="url_reg" value="student/Registration"></s:url>
                <s:url var="url_logout" value="student/logout"></s:url>
                <s:url var="url_Doctor_schedule" value="doctor/Schedule"></s:url>
                <s:url var="url_prescription" value="student/prescription"></s:url>


                <li><a href="#" class="navbar_single_link"><i class="fa fa-heartbeat"></i> Home</a></li>
                <li><a href="${url_reg}" class="navbar_single_link"><i class="fa fa-hospital-o"></i> Registration</a></li> 
                <li><a href="${url_log}" class="navbar_single_link"><i class="fa fa-plus-square"></i> Login</a></li> 
                <li><a href="${url_logout}" class="navbar_single_link"><i class="fa fa-motorcycle"></i> Logout</a></li> 
                <li><a href="${url_Doctor_schedule}" class="navbar_single_link"><i class="fa fa-user-md"></i> Doctor's Schedule</a></li> 
                <li><a href="${url_prescription}" class="navbar_single_link"><i class="fa fa-file"></i> Prescription</a></li> 

            </ul>

        </div>
        <script src="webjars/jquery/3.2.1/jquery.min.js"></script>
        <header>
            <h1>MEDICAL CENTER</h1>
            <h2>MAWLANA BHASHANI SCIENCE AND TECHNOLOGY UNIVERSITY</h2>
            <br>
            <br>
            
            <p>Register yourself for claiming the services provided by the medical center<br>You can keep track your prescription from anywhere.<br>It will help you to purchase medicine from any dispensary</p>
        </header>

        <script type="text/javascript" src="static/js/main.js">

        </script>


    </body>
</html>

这是我的registration.jsp文件的代码。

<%-- 
    Document   : registration
    Created on : Aug 9, 2018, 12:10:46 AM
    Author     : Noman Ibrahim
--%>



<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="f" %>

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@taglib uri="http://www.springframework.org/tags" prefix="s" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

        <!-- Optional theme -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

        <!-- Latest compiled and minified JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <link rel="stylesheet" href="static/css/stylerg.css">
        
        <title>Student Registration</title>

    </head>


    <body>
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-4 col-sm-4 col-xs-12"></div>
                <div class="col-md-4 col-sm-4 col-xs-12">
                    <!-- Form Start -->
                    <form>
                        <div class="form-group">
                            <label for="studentId">Your Student ID</label>
                            <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
                        </div>
                        <div class="form-group">
                            <label for="name">Your Name</label>
                            <input type="text" class="form-control" id="exampleInputPassword1" placeholder="Password">
                        </div>
                        <div class="form-group">
                            <label for="phone">Phone</label>
                            <input type="text" class="form-control" id="exampleInputPassword1" placeholder="Password">
                        </div>
                        <div class="form-group">
                            <label for="email">Email</label>
                            <input type="text" class="form-control" id="exampleInputPassword1" placeholder="Password">
                        </div>
                        <div class="form-group">
                            <label for="address">Current Address</label>
                            <input type="text" class="form-control" id="exampleInputPassword1" placeholder="Password">
                        </div>
                        <div class="form-group">
                            <label for="dept">Department</label>
                            <input type="text" class="form-control" id="exampleInputPassword1" placeholder="Password">
                        </div>
                        <div class="form-group">
                            <label for="session">Session</label>
                            <input type="text" class="form-control" id="exampleInputPassword1" placeholder="Password">
                        </div>
                        <div class="form-group">
                            <label for="password">Password</label>
                            <input type="text" class="form-control" id="exampleInputPassword1" placeholder="Password">
                        </div>
                        
                       
                       
                        <button type="submit" class="btn btn-success">Submit</button>
                    </form>

                    <!-- Form End -->
                </div>
                <div class="col-md-4 col-sm-4 col-xs-12"></div>

            </div>
        </div>
    </body>
</html>

我检查了命名错误。没有。请采取任何可能的解决方案?

0 个答案:

没有答案