<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<base href="http://localhost:8010/shop-resource/shop/"> //读取静态资源文件 和link拼接
<base th:href="${#servletContext.getContextPath()}">
//当路由访问到此服务时,一旦包含http://localhost:8010/shop-back/user/addUser,就跳转到template下的user目录下的 admin-add.html
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
//当路由访问到此服务时,一旦包含user/addUser,就跳转到template下的user目录下的 admin-add.html
registry.addViewController("user/getUserList").setViewName("user/admin-list");
registry.addViewController("user/addUser").setViewName("user/admin-add");
}
}
Feign
feign作为单独的服务模块,在back模块中使用feign去调用user的服务模块,获取数据,然后保存进model,back模块返回值为界面.html,而不再通过WebMvcConfigurer去跳转