出错代码:

@Configuration
public class Myconfig extends WebMvcConfigurationSupport{@Overridepublic void addViewControllers(ViewControllerRegistry registry) {registry.addViewController("/test").setViewName("success");}@Beanpublic WebMvcConfigurationSupport webMvcConfigurationSupport(){WebMvcConfigurationSupport aa = new WebMvcConfigurationSupport(){@Overrideprotected void addViewControllers(ViewControllerRegistry registry) {registry.addViewController("/boluo").setViewName("success");}} ;return aa;}}

出错原因:aa返回不回来,访问报错No mapping for GET ,原因 是把
@Bean下的
public WebMvcConfigurationSupport webMvcConfigurationSupport()
,此处不能用WebMvcConfigurationSupport ,应修改为public WebMvcConfigurer webMvcConfigurer(){
WebMvcConfigurer webMvcConfigurer = new WebMvcConfigurer()

关于静态资源不能访问的问题:
出现该问题是因为springboot 2.0后静态资源也经过拦截器导致的。
由于WebMvcConfigurerAdapter 的废弃,现今配置拦截器可使用 继承 WebMvcConfigurationSupport 类和实现 WebMvcConfigurer接口 两种方法。
建议采用后一种方法(实现接口),否则会出现如题所示的方法。
如果坚持使用继承WebMvcConfigurationSupport类 的方法,则必须要覆盖重写WebMvcConfigurationSupport类 的

protected void addResourceHandlers(ResourceHandlerRegistry registry);

具体如下:

@Overrideprotected void addResourceHandlers(ResourceHandlerRegistry registry) {registry.addResourceHandler("/**").addResourceLocations("classpath:/static/").addResourceLocations("classpath:/templates/");super.addResourceHandlers(registry);}

SpringBoot使用thymefeal出现No mapping for GET /xxx的解决办法相关推荐

  1. springboot上传大文件时内存溢出的可能解决办法

    springboot上传大文件时内存溢出的可能解决办法 在springboot中上传大文件时要考虑内存的情况,一般我们会通过在执行服务时加入-Xms512m -Xmx512m等参数加大堆内存,但这是指 ...

  2. Spring Data ElasticSearch analyzer 定义 @Filed失效 @Mapping失效 创建索引 无效 解决办法 ElasticsearchRestTemplate

    ES版本 7.x 首先上失效原因 SpringDataElasticsearch版本变动频繁,很多网上的代码失效,有很多方法标记为过时 ElasticsearchRestTemplate不读@File ...

  3. SpringBoot项目的pom.xml文件中maven-project-info-reports-plugin报红解决办法

    今天在创建SpringBoot项目时发现导包是没有任何问题的,但是pom文件中maven-project-info-reports-plugin一直有报红,如下图所示: 解决方案: 在该pom文件中引 ...

  4. SpringBoot启动报错:HikariPool-1 - Exception during pool initialization.解决办法

    SpringBoot启动报错:HikariPool-1 - Exception during pool initialization. 记一次Maven项目部署http访问mysql数据库过程中的问题 ...

  5. SpringBoot整合freemarker找不到静态资源ftl文件解决办法

    1.检查是否引入freemarker依赖 <dependency><groupId>org.springframework.boot</groupId><ar ...

  6. springboot项目每次启动的时候都会跳进一个异常解决办法

    windows apperences 这个地方的勾去掉就可以了

  7. springboot 2.0中 PUT请求 接收不到参数解决办法

    在做RestTemplate调用,springboot2.0 swagger2接口时候,参数通过HandlerInterceptorAdapter 拦截后,在controller里面获取不到  解决办 ...

  8. IDEA+Maven+Springboot:invalid bound statement (not found) 解决办法

    自己使用Springboot搭建web项目,之前都是使用注解形式来执行sql获取查询内容,这次本承着闲得无聊试一试的想法,突发奇想想用xml的方式执行sql.很走心的参照自己之前spring项目的书写 ...

  9. springboot集成swagger2多模块中文配置详细步骤,解决集成mybatis或mybatis-plus无法正常使用问题

    springboot集成swagger2多模块中文配置详细步骤,解决集成mybatis或mybatis-plus无法正常使用问题 参考文章: (1)springboot集成swagger2多模块中文配 ...

  10. IDEA中进行SpringBoot开发时提示:Error resolving template xxx, template might not exist or might not be acce

    场景 IDEA中进行SpringBoot开发时提示: Error resolving template "xxx", template might not exist or mig ...

最新文章

  1. 非侵入脑机接口新突破!用意念控制光标,连续追踪效果提升5倍
  2. 编写MOSS自定义字段类型的小意外
  3. Zedboard学习(四):PS+PL搭建SoC最小系统
  4. es6 --- 数组的扩展
  5. Java默认类型,类型转换,常量与变量笔记
  6. selenium+chromeheadless爬取网站
  7. 题解【luogu P2421 bzoj P1407 [NOI2002]荒岛野人】
  8. Java发送邮箱验证码、session校验功能
  9. RK平台计算GPIO对应的整型数
  10. Jquery对话框基本配置
  11. 数学建模——相关系数、皮尔逊相关系数、斯皮尔曼相关系数
  12. 关于GitHub如何转为中文问题——Google举例
  13. ns3网络设置模块 PointToPoint
  14. Unity官网注册账号绑定手机国籍更改失败
  15. 番外2. OpenCV 中摄像头捕获与视频处理与常见问题解决方案
  16. 打开excel提示损坏的映像的解决办法
  17. Linux下 安装白鹭(egret)引擎指南
  18. 网线还能这样玩???(哈哈哈,记一次差点被揍事件)
  19. Google 重申对 Kotlin 编程语言 Android 的承诺:谷歌推出 Kotlin 免费在线课程 Kotlin Bootcamp Course 2
  20. 现代笑话二则:1、马尾辫同学;2、辣椒惹的祸。

热门文章

  1. 关于前端惰性加载(jquery_lazyload)的使用和原理分析
  2. Java经典编程题50道之二十四
  3. 1.1 OC类的认识
  4. HttpClient 教程 (六)
  5. 网络工程师Day2---实验2-1:HDLC和PPP配置
  6. IPv6 gre隧道、路由协议综合实验(华为设备)
  7. 华为IS-IS基础配置
  8. Linux下学习进程控制
  9. 用ifconfig命令,只有lo,没有eth0的解决方案
  10. python自动化学习之语法学习(判断语句和循环语句)