26.springboot转发和重定向
2018-10-18 本文已影响0人
木有鱼丸啦
1.
@Controller
@SpringBootApplication
public class ProductApplication {
@RequestMapping("/")
String index() {
return "redirect:index.html";
}
public static void main(String[] args) {
SpringApplication.run(ProductApplication.class, args);
}
}
2.使用thymeleaf
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
@Controller
@SpringBootApplication
public class ProductApplication {
@RequestMapping("/")
String index() {
return "templates";
}
public static void main(String[] args) {
SpringApplication.run(ProductApplication.class, args);
}
}