---
title: "@RequestBody与@RequestParam"
author: "H小阿飞"
date: "2016-11-24T13:28:21Z"
tags: []
categories: ["编程语言"]
slug: "requestbody-requestparam"
draft: false
lastmod: "2016-11-24T13:28:21Z"
id: 2340858
url: "https://tim-fly.iteye.com/blog/2340858"
---

@RequestParam 跟get结合使用

 

如果@RequestParam与post使用的话，就要使用form形式请求，不能用json了

 

还有RequestParam提交的时候，是content-type为form，RequestBody提交的时候 content-type为json

 

所以一个接口里面，不能同时有RequestParam和RequestBody两个注解

 

你不写RequestParam，ajax提交的时候，也是默认的form提交

 

如果ajax提交的时候， content-type设置为json，而接口为RequestParam就不行