一个视图跳转的例子.
package com.xuxing.study2.config;
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 MyMvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/xuxing").setViewName("xu");
}
}
添加对应的视图 templates/xu.html
运行效果如图
官方的建议,扩展方式。
如果加 @EnableWebMvc 后, 则扩展了 webMvcConfigurationSupport 而 mvc 有conditionNo on webMvcConfigurationSupport ,
- 视图解析器。
- 格式转换器。
- 消息转换器
未完待续,后续补充。