我正在研究spring框架,并在互联网上学习了一些教程,然后我发现了这个:
package control;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MVCController implements WebMvcConfigurer {
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/index").setViewName("index");
registry.addViewController("/").setViewName("index");
registry.addViewController("/hello").setViewName("hello");
registry.addViewController("/login").setViewName("login");
}
}
所以我的疑问是:
如何在不添加新行的情况下放置更多页面以将视图控制器添加到每个页面?
有一些方法可以将一些通用控制器放到我不打算进行一些处理的页面上?(例如一些静态页面)
我正在使用 spring 5 和 Java JRE 1.8。
谢谢!