我丢失了通过控制器时看到的格式

时间:2019-03-14 09:26:50

标签: java spring-boot controller thymeleaf

我在执行控制器的操作时遇到问题。

将动作发送到控制器时,这是通过视觉提取数据。

在我的控制台中,我看到在css和js的加载行中添加了控制器操作,但我不知道如何删除它。

Refused to apply style from 'http://localhost:8080/editReport/css/style.css' because its MIME type ('application/json') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
2:1 Refused to apply style from 'http://localhost:8080/editReport/static/css/sandstone/bootstrap.css' because its MIME type ('application/json') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
2:1 Refused to apply style from 'http://localhost:8080/editReport/css/sandstone/bootstrap.css' because its MIME type ('application/json') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

驱动程序的表单输出

<td>
   <a th:href="@{/editReport/__${report.id}__}" class="btn btn-warning pull-left">
    <span class="glyphicon glyphicon-trash">
</span> Edit Report
   </a>
</td>

控制器动作

@RequestMapping(method=RequestMethod.GET, path = "/editReport/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    public String edit(@PathVariable Long id , Model model) {
        model.addAttribute("report", reportService.findOne(id));
        return "views/report_form_edit";
    }

退出视图

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{fragments/main_layout}">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
    <title>Register Form</title>
</head>
<body>

<div layout:fragment="content" class="container sandstone">
    <form th:action="@{/saveReport}" th:object="${report}" method="post">
        <input type="hidden" class="form-control" th:field="*{id}" id="id"/>
        <div class="form-group">
            <label for="date" class="form-control-label">Date</label>
            <input type="text" class="form-control" th:field="*{date}" id="date"/>
            <div class="text text-danger" th:if="${#fields.hasErrors('date')}" th:errors="*{date}"></div>
        </div>
        <div class="form-group">
            <label for="title" class="form-control-label">Title</label>
            <input type="text" class="form-control" th:field="*{title}" id="title"/>
            <div class="text text-danger" th:if="${#fields.hasErrors('title')}" th:errors="*{title}"></div>
        </div>
        <div class="form-group">
            <label for="link" class="form-control-label">Link</label>
            <input type="text" class="form-control" th:field="*{link}" id="link"/>
            <div class="text text-danger" th:if="${#fields.hasErrors('link')}" th:errors="*{link}"></div>
        </div>
        <div class="form-group">
            <label for="description" class="form-control-label">Description</label>
            <textarea class="form-control" th:field="*{description}" id="description">  </textarea>
            <div class="text text-danger" th:if="${#fields.hasErrors('description')}" th:errors="*{description}"></div>
        </div>
        <input type="submit" value="Save" class="btn btn-primary"/>
    </form>
</div>
</body>
</html>

main_layout

<!DOCTYPE html>
<html xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
      xmlns:th="http://www.w3.org/1999/xhtml"
      xmlns:layout="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
    <link rel="stylesheet" th:href="@{css/style.css}"/>
    <link rel="stylesheet" th:href="@{static/css/sandstone/bootstrap.css}">
    <link rel="stylesheet" th:href="@{css/sandstone/bootstrap.css}"/>
    <script th:src="@{|/webjars/jquery/jquery.min.js|}"></script>
    <script th:src="@{|/webjars/bootstrap/bootstrap.min.js|}"></script>
</head>
<body>
<div th:replace="fragments/header::header"></div>
<div layout:fragment="content" class="contenedor sandstone"></div>
<div th:replace="fragments/footer::footer"></div>
</body>
</html>

0 个答案:

没有答案