Spring Boot MVC - problem z widokiem

0

Witam, mam pewien problem. Napisałem prosty kontroler który ma wyświetlić html'a. Plik html wrzuciłem do katalogu recources/templates.
Sprawdziłem, że kontroler się uruchamia po wejściu na odpowiedni endpoint, ale nie wyświetla widoku. Kod z kontrolera udostępniam poniżej.

@Controller
public class CosController {

	@GetMapping("/formularz")
	public String form() {
		System.out.println("Dziala!!!!!!!");
		return "form";
	}
}

Oczywiście plik widoku nazywa się form.html

0

Wszystko robiłem wg tutoriala z tej strony
https://spring.io/guides/gs/serving-web-content/
I z tego co rozumiem to wszystkie konfiguracje załatwia spring boot, html wrzucony do domyślnego folderu etc.

0

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.5.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>pl.szycha</groupId>
	<artifactId>ApkaMvc</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<name>Form2</name>
	<description>test mvc</description>

	<properties>
		<java.version>11</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>com.h2database</groupId>
			<artifactId>h2</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

0

Link do githuba albo cokolwiek, bo inaczej to można wróżyć z fusów.

0

Po dodaniu linijki poniżej do html wszystko działa, nie wiem dlaczego ale tak jest.

xmlns:th="http://www.thymeleaf.org"

1 użytkowników online, w tym zalogowanych: 0, gości: 1