Use controller in Spring Boot sample

Issue gh-1647
This commit is contained in:
Eleftheria Stein
2020-09-14 19:04:54 +02:00
parent 068ed8d355
commit a9c2336482

View File

@@ -16,16 +16,15 @@
package sample.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Controller
public class IndexController {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index");
@RequestMapping("/")
public String index() {
return "index";
}
}