У меня есть простое веб-приложение Spring.
@Controller
public class GreetingController {
@Autowired
GreetingRepository repository;
@GetMapping("/greeting")
public String greetingForm(Model model) {
model.addAttribute("greeting", new Greeting());
return "greeting";
}
@PostMapping("/greeting")
public String greetingSubmit(@ModelAttribute Greeting greeting) {
repository.save(greeting);
return "result";
}
}
HTML-код:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Greeting Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" th:href="@{/css/style.css}"/>
</head>
<body>
<h1>Form</h1>
<form action="#" th:action="@{/greeting}" th:object="${greeting}" method="post">
<p>Id: <input type="text" th:field="*{id}" /></p>
<p>Message: <input type="text" th:field="*{content}" /></p>
<p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
</form>
</body>
</html>
Это файл CSS, на который есть ссылка в HTML:
p {
color: #ff5588;
}
Однако css не применяется.
Фактически, когда я запрашиваю localhost: 8080 / css / style.css, он возвращает HTML-содержимое страницы индекса.