0

I have an API for front side,I use postman to send a single number 8.

I want to send like this way in Postman

@RequestMapping(value="/query",method=RequestMethod.POST)
@ResponseBody
public String query(@RequestBody Integer number ){  

    return dao.query(number);
}

but now the front side say they can not send a single word with no key-value in json,I don't want to create an object just use that once to binding, how can I do this?

2 Answers 2

1

Have a look at requestparam

@RequestMapping(value = "/query", method=RequestMethod.POST)
@ResponseBody
public String query(@RequestParam("number") Integer number){
  return dao.query(number);
}

The request should be like /query?number=8

Sign up to request clarification or add additional context in comments.

2 Comments

@detail0805 that is not possible,,,when you say json it means key value pair is must.
ok,I check it for js api,it will be possible to send single parameter ,but its not officially ...so you are the right .
0

Change Integer to String and you are good to go without doing anything else. Hope this helps you.

@RequestMapping(value="/query",method=RequestMethod.POST)
 @ResponseBody
 public String query(@RequestBody String number ){  

      return dao.query(number);
 }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.