As @araknoid said - you can create a wrapper:
public class ShopListResponse {
private List<ShopDetails> shopList;
private String message;
public ShopListResponse (List<ShopDetails> shopList, String message){
this.shopList = shopList;
this.message = message;
}
}
In the controller class:
@RequestMapping(value = "/SubmitStep1.json", method = RequestMethod.POST, headers = "Accept=application/json,application/xml")
@ResponseBody
public ResponseEntity<ShopListResponse> showShopList(@RequestBody ShopDetails shopDetails)throws Exception{
List<ShopDetails> shopDetailsList = dbq.getShopDetails(shopDetails);
return new ResponseEntity<>(new ShopListResponse(shopDetailsList, "Success or error message"), HttpStatus.OK);
}
If you want to return an error - you can return HttpStatus.NOT_FOUNDor just return an HttpStatus.OKerror message - it depends on your approach.
Here's the result of the controller: 
Optio source
share