Write a configuration class that extends Spring MVC:
package com.ckh.springboot04.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
//继承WebMvcConfigurerAdapter扩展mvc
@Configuration
public class MyMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
//浏览器发送 “/index” 请求,来到 success
registry.addViewController("/ckh").setViewName("success");
}
}
Since there is no understanding of what this means, resulting in an error.
registry.addViewController("/ckh").setViewName("success");
In fact, this component is in Riga to a view controller, when you visit localhost: 8080 / ckh time, will jump to success.html this page,
I did not write a page called success, so the displayed web page can not be found.
Well, actually this is usually extended configuration class role is to write a class configured for Jump homepage:
registry.addViewController("/").setViewName("index");