春の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");
}
}
エラーとなったものを、この意味のない理解し、存在しないので。
registry.addViewController("/ckh").setViewName("success");
、8080 / CKH時間をこのページをsuccess.htmlにジャンプします、:あなたはlocalhostを訪問したときに実際には、このコンポーネントは、ビューコントローラにリガにある
表示されたウェブページを見つけることができないので、私は、成功と呼ばれるページを書いていません。
まあ、実際にこれは通常、拡張されたコンフィギュレーションクラスの役割は、ジャンプのホームページ用に構成されたクラスを作成することです:
registry.addViewController("/").setViewName("index");