使用postman发送json数据
今天在使用postman测试post请求时,发送的数据总是为null,纠结了我一会儿,后来成功解决,在此记录一下
问题产生原因
post请求头中没有设置为json数据格式,而后端使用了@RequstBody注解,因此提取不了json数据。
解决方法
在请求头中加入Content-Type=application/json
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent:
meta: false
pages: false
posts:
title: true
date: true
path: true
text: false
raw: false
content: false
slug: false
updated: false
comments: false
link: false
permalink: false
excerpt: false
categories: false
tags: true