Я теряю формат при просмотре через контроллер - PullRequest
0 голосов
/ 14 марта 2019

У меня проблема с выполнением действия моего контроллера, выполняющего crud.

при отправке действия в контроллер, и это для извлечения данных визуально.

В моей консоли явижу, что в строке загрузки 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>
...