In a controller class,
I have one method
@RequestMapping(value="test", method={RequestMethod.POST,RequestMethod.PUT})
@ResponseBody
public String testApp(@RequestParam String priceA, @RequestBody String valueOfProduct) throws Exception {
}
My client is sending prices to my App as POST requests for processing.
Now client (which is not under my control) is planning to send the price value as a request parameter and another client is planning to send price in requestheader.
The trick is: If it is present in requestheader it wont be present in requestparameter.
So I have to design it such that my server code works fine in both cases.
Kindly let me know which design would be the best.
Will it be
@RequestMapping(value="test", method={RequestMethod.POST,RequestMethod.PUT})
@ResponseBody
public String testApp(@RequestParam String priceA, @RequestHeader("PRICE") String priceAFromAnother, @RequestBody String valueOfProduct) throws Exception {
}
But above logic wont work as @RequestParam wont be available all the time.