Springboot中如何自定义一个html的名称
1.自定义一个类去实现WebMvcConfigurer ,并且在上面注明是@Configuration,以便被扫描到是配置
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MyConfig implements WebMvcConfigurer {
//这里就是建立一个视图别名的地方了
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login.html").setViewName("login");
}
}
2.测试一下看看能不能用
@Controller
public class MyController {
@RequestMapping("/login")
public Object getShe(@RequestParam("user") Str