Когда я нажимаю на ссылку в home.html , Spring сообщает GET - ресурс не найден .
В home.th.xml вы увидите, что он говорит, чтобы кричать на сопоставления (и я предполагаю, что именно так @GetMapping обслуживает каталог-home).
[РЕДАКТИРОВАТЬ] Добавлен DecoupledLogic.java в проект
[EDIT] Добавлен файл MvcConfig (существовал в проекте)
MvcConfig.java
@Configuration
public class MvcConfig implements WebMvcConfigurer {
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName(ViewNames.HOME);
registry.addViewController("home").setViewName(ViewNames.HOME);
}
}
BookCatalogController.java
@Slf4j
@Controller
public class BookCatalogController {
// == Request methods ==
// Catalog Simple View
@GetMapping("Mappings.CATALOG_SIMPLE")
public String catalogSimple(Model model){
log.info("catalogSimple method called");
return ViewNames.CATALOG_SIMPLE;
}
Mappings.java
// For mapping LINKS to views
public class Mappings {
// Welcome homepage
public static final String HOME = "home";
// Catalog views
public static final String CATALOG_SIMPLE="catalog-simple";
// psfs CATALOG_DETAIL = "catalog-detail";
//== constructor
private Mappings(){}
}
ViewNames.java
public class ViewNames {
public static final String HOME = "home";
public static final String CATALOG_SIMPLE="catalog-simple";
//==constructor
private ViewNames(){}
}
каталог-simple.html
<!DOCTYPE html>
<html lang="en">
<head id="headId">
<meta charset="UTF-8">
<title>Title content</title>
</head>
<body>
HELLO
</body>
</html>
DecoupledLogic.java
@Slf4j
@Component
public class DecoupledLogicSetup {
// == fields ==
private final SpringResourceTemplateResolver templateResolver;
// == constructor
public DecoupledLogicSetup(SpringResourceTemplateResolver templateResolver) {
this.templateResolver = templateResolver;
}
// == init ==
@PostConstruct
public void init() {
templateResolver.setUseDecoupledLogic(true);
log.info("Decoupled template logic enabled");
}
}
home.html
<!DOCTYPE html>
<html lang="en">
<head id="headId">
<meta charset="UTF-8">
<title>Title content</title>
</head>
<body>
<div align="center">
<h1 id="welcomeMessage"></h1>
<h3>
<a id="goToCatalogSimple"
href="catalog-simple.html">Go to catalog
</a>
</h3>
</div>
</body>
</html>
home.th.xml
<attr sel="#goToCatalogSimple"
th:href="@{__${T(com.potatospy.bookcatalog.util.Mappings).CATALOG_SIMPLE}__}"
th:text="#{bc.welcome.gosimplecatalog}"/>
</thlogic>
LOG
2019-01-18 18:31:35.154 DEBUG 10948 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet : GET "/catalog-simple", parameters={}
2019-01-18 18:31:35.155 DEBUG 10948 --- [nio-8080-exec-4] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2019-01-18 18:31:35.156 DEBUG 10948 --- [nio-8080-exec-4] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2019-01-18 18:31:35.157 DEBUG 10948 --- [nio-8080-exec-4] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found