I am having some issues with a controller in spring boot. Which should return an index.html file but what it doing is, returning the string "index".
Here are the things you want to look for,
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>
<groupId>com.earworm</groupId>
<artifactId>earworm</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The controller named LoginController.java
package com.earwormproject.earwormcontrollers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class LoginController {
@RequestMapping(value = "/index", method = RequestMethod.GET)
@ResponseBody
public String createLoginForm(){
return "index";
}
@RequestMapping(value = "/profile", method = RequestMethod.GET)
@ResponseBody
public String addDataToLoginForm() {
return "profile";
}
}
Here is the main class,
package com.earwormproject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Earworm {
public static void main(String[] args){
SpringApplication.run(Earworm.class, args);
}
}
The file structure,
Earworm is the main class.So far I know controller checks for the html templates in the src/main/resources/templates, I have put the index.html in templates, did not work.
When I am going to http://localhost:8080/index it is showing me the string index instead of the index.html page. Like this,
I have gone through almost all the similar questions here in SO, tried all those but did not work in this case. Some clue will be of great help. Thank you.

