导入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

统一路径映射

相关文章:

  • 2021-11-03
  • 2021-11-30
  • 2021-12-24
  • 2021-11-04
  • 2021-12-30
  • 2021-05-17
  • 2022-12-23
  • 2021-06-10
猜你喜欢
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案