最近在跟雷神学习SpringBoot在学习通过@GetMapping获取url中的路径变量参数等数据时网页报This XML file does not appear to have any style information associated with it,在网上找了一圈,后来发现是config包下的webconfig配置文件出了问题,用官方文档中的代码替换掉就好、官方文档中的代码如下

@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {

  /**
    * Setup a simple strategy: use all the defaults and return XML by default when not sure. 
    */
  @Override
  public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_XML);
  }
}

具体原因就是在识别网页时,将html错误的识别为xml文件,而html文件中没有引入样式,自然得不到想要的json数据

最后给大家推荐jsonview插件,是真滴好用

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐