访问html网页返回数据是json时网页端报This XML file does not appear to have any style information associated with it

最近在跟雷神学习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插件,是真滴好用

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值