春ブーツは报错:このアプリケーションは/エラーのための明示的なマッピングを持っていません

春の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");
リリース6元記事 ウォンの賞賛3 ビュー534

おすすめ

転載: blog.csdn.net/bulubulua/article/details/104760945