无法在jsp页面中找到资源

时间:2018-10-23 06:59:34

标签: spring-mvc jsp

我已将外部CSS放在 webapp-> resources-> css文件夹上。 但是一些特定的jsp,无法找出我的资源。 示例:

 @GetMapping(value = "/divisionlist")
    public String divisionlist(Model model) {
        model.addAttribute("division", new Division());
        model.addAttribute("divisionlists", this.divisionService.listdivisions());
        return "divisionlist";
    }

这是一页的控制器。在此页面中,很好地添加了资源。 This is list page

当我检查页面时,请求网址是这样的,这是正确的:

  

http://localhost:8090/farmvill/resources/css/bootstrap.min.css

但是当我单击显示按钮时,无法加载资源。

This is show page

当我检查页面时,请求网址是这样的,这是不正确的:

  

http://localhost:8090/farmvill/show/resources/css/bootstrap.min.css

显示页面的控制器:

@GetMapping("/show/{id}")
    public String showDivision(@PathVariable("id") int id, Model model) {

        model.addAttribute("division", this.divisionService.getdivisionById(id));
        return "showdivision";
    }

列表页面的jsp页面:

> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@
> taglib uri="http://www.springframework.org/tags" prefix="spring" %>
> <%@ taglib uri="http://www.springframework.org/tags/form"
> prefix="form" %> <%@ page session="false" %> <!DOCTYPE html> <!--[if
> lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
> <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
> <!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
> <!--[if gt IE 8]>      <html class="no-js"><!--> <!--<![endif]-->
> <html>   <head>
>     <meta name="description" content="">
>     <meta name="viewport" content="width=device-width">
>     <meta charset="utf-8">
>     <title>Firm Life</title>
>     <!--bootstrap css-->
>     <link rel="stylesheet" href="resources/css/bootstrap.min.css" />
>     <!--font-awesome css-->
>     <link rel="stylesheet" href="resources/css/font-awesome.min.css" />
>     <!--app css-->
>     <link rel="stylesheet" href="resources/css/app.css" />
>     <!--css for this template-->
>     <link rel="stylesheet" href="resources/css/main.css" />
>      <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
>   <script
> src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
>   <script
> src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
> </head>   <body>
> 
> <header class="area">
>     <section class="header-section area">
>       <article class="container-fluid">
>         <div class="header-content">
>           <div class="header-logo">
>             <h2 class="logo"><a href="#">Firm Life</a></h2>
>           </div>
>           <!-- End of header-logo -->
>         </div>
>         <!-- End of header-content -->
>       </article>
>       <!-- End of container-fluid -->
>     </section>
>     <!-- End of header -->   </header>   <!-- End of header -->
> 
>   <main class="area">
>     <section class="main-body-content area">
>        <div class="replace"></div>
>      
>       <!-- End of sidebar menu -->
>         <article class="container-fluid">
>         <div class="row">
>           <div class="col-sm-9 col-sm-offset-3">
>             <div class="create-form list-form">
>               <h2 class="page-title">Division List</h2>
>               <form action="" class="table-responsive">
>                 <div class="sel-group area text-center">
>                
>                 <!-- End of sel-group -->
>                 <table class="create-table table table-hover table-bordered">
>                   <thead>
>                     <tr>
>                       <th>ID</th>
>                       <th>Name</th>
>                       <th>edit</th>
>                       <th>show</th>
>                       <th>delete</th>
>                     </tr>
>                   </thead>
>                   <!-- End of thead -->
>                   <tbody>
>                     <c:forEach items="${divisionlists}" var="division">
>                       <tr>
>                           <td>${division.id}</td>
>                           <td>${division.name}</td>
>                           <td><a href="<c:url value='edit/${division.id}' />"  class="btn site-btn filled-btn edit-btn">Edit</a></td>
>                            <td><a href="<c:url value='show/${division.id}' />"  class="btn site-btn filled-btn edit-btn">Show</a></td>
>                           <td><a href="<c:url value='remove/${division.id}' />" class="btn site-btn filled-btn delete-btn">Delete</a></td>
>                       </tr>
>                      
>                   </c:forEach>
>                  
>                     <!-- End of tr -->
>                   </tbody>
>                   <!-- End fo tbody -->
>                 </table>
>                 <!-- End of table -->
>               </form>
>               <!-- End of form -->
>             </div>
>             <!-- End of farmer create form -->
>           </div>
>           <!-- End of col -->
>         </div>
>         <!-- End of row -->
>       </article>
>       <!-- End of container -->
>     </section>
>     <!-- End of main-content-section -->   </main>   <!-- End of main -->
> 
>   <footer class="area">
>     <section class="footer-section area">
>       <article class="container-fluid">
>         <div class="row">
>           <div class="col-sm-6">
>             <div class="footer-logo">
>               <a href="#">Auto Irrigation</a>
>             </div>
>             <!-- End of footer-logo -->
>           </div>
>           <!-- End of col -->
>           <div class="col-sm-6">
>             <div class="footer-copyright">
>               <p>&copy; 2018 | All rights reserved</p>
>             </div>
>             <!-- End of footer-copyright -->
>           </div>
>           <!-- End of col -->
>         </div>
>         <!-- End of row -->
>       </article>
>       <!-- End of container-fluid -->
>     </section>
>     <!-- End of footer -->   </footer>   <!-- End of footer -->
> 
>   <!-- End of footer -->
>     <script src="resources/js/siderbar.js"></script>
>     <script src="resources/js/bootstrap.min.js"></script>
>     <script src="resources/js/main.js"></script>   </body> </html>

要显示的jsp页面:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]>      <html class="no-js"><!--> <!--<![endif]-->
<html>
  <head>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width">
    <meta charset="utf-8">
    <title>Firm Life</title>
    <!--bootstrap css-->
    <link rel="stylesheet" href="resources/css/bootstrap.min.css" />
    <!--font-awesome css-->
    <link rel="stylesheet" href="resources/css/font-awesome.min.css" />
    <!--app css-->
    <link rel="stylesheet" href="resources/css/app.css" />
    <!--css for this template-->
    <link rel="stylesheet" href="resources/css/main.css" />
     <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
  </head>
  <body>

<header class="area">
    <section class="header-section area">
      <article class="container-fluid">
        <div class="header-content">
          <div class="header-logo">
            <h2 class="logo"><a href="#">Firm Life</a></h2>
          </div>
          <!-- End of header-logo -->
        </div>
        <!-- End of header-content -->
      </article>
      <!-- End of container-fluid -->
    </section>
    <!-- End of header -->
  </header>
  <!-- End of header -->

  <main class="area">
    <section class="main-body-content area">
       <div class="replace"></div>

      <!-- End of sidebar menu -->
        <article class="container-fluid">
        <div class="row">
          <div class="col-sm-9 col-sm-offset-3">
            <div class="create-form list-form">
              <h2 class="page-title">Details of Division</h2>
              <form action="" class="table-responsive">
                <div class="sel-group area text-center">

                <!-- End of sel-group -->
                <table class="create-table table table-hover table-bordered">
                  <thead>
                    <tr>
                      <th>ID</th>
                      <th>Name</th>
                    </tr>
                  </thead>
                  <!-- End of thead -->
                  <tbody>
                        <tr>
                            <td>${division.id}</td>
                            <td>${division.name}</td>
                        </tr>

                    <!-- End of tr -->
                  </tbody>
                  <!-- End fo tbody -->
                </table>
                <!-- End of table -->
              </form>
              <!-- End of form -->
            </div>
            <!-- End of farmer create form -->
          </div>
          <!-- End of col -->
        </div>
        <!-- End of row -->
      </article>
      <!-- End of container -->
    </section>
    <!-- End of main-content-section -->
  </main>
  <!-- End of main -->

  <footer class="area">
    <section class="footer-section area">
      <article class="container-fluid">
        <div class="row">
          <div class="col-sm-6">
            <div class="footer-logo">
              <a href="#">Firm Life</a>
            </div>
            <!-- End of footer-logo -->
          </div>
          <!-- End of col -->
          <div class="col-sm-6">
            <div class="footer-copyright">
              <p>&copy; 2018 | All rights reserved</p>
            </div>
            <!-- End of footer-copyright -->
          </div>
          <!-- End of col -->
        </div>
        <!-- End of row -->
      </article>
      <!-- End of container-fluid -->
    </section>
    <!-- End of footer -->
  </footer>
  <!-- End of footer -->

  <!-- End of footer -->
    <script src="resources/js/siderbar.js"></script>
    <script src="resources/js/bootstrap.min.js"></script>
    <script src="resources/js/main.js"></script>
  </body>
</html>

文件夹格式:

This is folder formation

0 个答案:

没有答案