统一路径映射
导入thymeleaf依赖
hello.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
hello
</body>
</html>
HelloController
@Controller
public class HelloController {
@GetMapping("/hello")
public String hello(){
return "hello";
}
}
统一注册 即可以不需要上面的controller
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/qwl").setViewName("hello");
}
}
然后可以直接访问http://localhost:8080/qwl