Redirect to an html with Spring Boot

0

I'm starting to create applications with Spring Boot + Gradle, but when configuring the Controller, I can not redirect a url to a html or jsp file.

My application looks like this:

Projectstructure:

MyController:

Thepagedisplayedby link is a blank page written: login.html and not displaying the html that I put in the static folder

I saw some similar cases but all the answers I found did not work, so I thought I'd like to open a new topic.

    
asked by anonymous 14.07.2018 / 20:36

2 answers

0

I was able to resolve this:

Creating RequestMapping on Controller

@RequestMapping("/")
   public ModelAndView index(){
   return new ModelAndView("index");
}

Other than yours, it returns a ModelAndView , which will pull the page from within resources/templates/ .

Creating a Dependency in pom.xml

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

And to finish, have the page index.html within resources/templates/ .

    
09.11.2018 / 19:13
0

Make the following change in your endpoint

@RequestMapping("/")
public String index() {
    return "login";
}
    
09.11.2018 / 19:27