获取http://localhost:8088/edit/css/style.css net::err\u中止404 springboot

nkhmeac6  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(281)

嘿,希望你们都做得好,我希望我能在这里得到正确的答案,并提前谢谢你们。所以我一直在用springboot做一个crud项目,实际上一切都很好,就在我尝试重定向到编辑页面时,浏览器显示了这个错误 GET http://localhost:8088/edit/css/style.css net::ERR_ABORTED 404 . 澄清编辑页面无法加载css文件。这是我的代码,如果你想深入研究
控制器:

package com.crm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.crm.model.Customer;

import com.crm.service.crmService;

@Controller
public class CrmController {

    @Autowired
    crmService service;

    @RequestMapping(value="/")
    public String acceuil() {
        return "acceuil";
    }

    @RequestMapping(value="/list")
    public String viewHomePage(Model model) {
        List<Customer> listcustomer = service.listAll();
        model.addAttribute("listcustomer", listcustomer);
        System.out.print("Get / "); 
        return "index";
    }

    @RequestMapping(value="/new")
    public String add(Model model) {
        model.addAttribute("customer", new Customer());
        return "new";
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public String saveStudent(@ModelAttribute("customer") Customer std) {
        service.save(std);
        return "redirect:/list";
    }

    @RequestMapping("/edit/{id}")
    public ModelAndView showEditStudentPage(@PathVariable(name = "id") int id) {
        ModelAndView mav = new ModelAndView("new");
        Customer ctr = service.get(id);
        mav.addObject("customer", ctr);
        return mav;

    }
    @RequestMapping("/delete/{id}")
    public String deletestudent(@PathVariable(name = "id") int id) {
        service.delete(id);
        return "redirect:/list";
    }
}

编辑页面:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <title>Gérer les Clients</title>
 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<link rel="stylesheet" href="../static/css/style.css" th:href="@{css/style.css}"/>

</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <img  src="../static/images/afro.png" th:src="@{images/afro.png}" class="nav-img" href="#"/>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" th:href="@{'/'}">Accueil</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" th:href="@{'/list'}">list des clients</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" th:href="@{'/new'}">Ajouter un client</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
<div id="carouselExampleSlidesOnly" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="../static/images/cover4.png" th:src="@{images/cover4.png}" class="d-block w-100" alt="...">
    </div>
  </div>
</div>
<div align="center">
    <h1>Gérer les Clients</h1>
    <br/>
     <div class="col-sm-4">
    <form action="#" th:action="@{/save}" th:object="${customer}" method="post">

        <div alight="left">
            <tr>
                <td>
                    <input type="hidden" th:field="*{id}" />
                    <input type="text" th:field="*{nom}" class="form-control" placeholder="Nom client" />
                </td>
            </tr>
         </div>   

            <div alight="left">

            <tr>
                <td><input type="text" th:field="*{prenom}" class="form-control" placeholder="Prenom" /></td>
            </tr>
            </div> 
            <div alight="left">
                 <tr>
                <td><input type="text" th:field="*{Email}" class="form-control" placeholder="Email" /></td>
            </tr>
            </div> 

             <div alight="left">
                 <tr>
                <td><input type="text" th:field="*{numero}" class="form-control" placeholder="Numero de telephone" /></td>
            </tr>
            </div>

             <div alight="left">
                 <tr>
                <td><input type="text" th:field="*{produit}" class="form-control" placeholder="Produit" /></td>
            </tr>
            </div>  
            <br>
            <tr>
            <td colspan="2"><button type="submit" class="btn btn-info">Enregistrer </button> </td>
            </tr>
        </table>
    </form>

</div>
<div class="space"></div>

</body>
</html>

再次感谢大家的帮助,我期待着你们的回答

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题