1.目的
访问http://localhost:8090/即可进入首页(http://localhost:+端口号)
2.首页index.jsp
首页放在该路径下
3. 访问设置
重写WebMvcConfigurer类中的addViewControllers()方法:页面跳转。(直接这样写就行)
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class DefaultView implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("WEB-INF/").setViewName("forward:index.jsp");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
}