To pass a value to java I have used post method from AngularJs to my java code and it works just fine to do what i needed and my code is as the followoing :
@RequestMapping(value="/shelf", method=RequestMethod.POST, consumes="application/json")
public void getSelectedShelf(@RequestBody String shelf) throws JSONException {
logger.debug("Start uploading the files...");
logger.debug(shelf.toString());
JSONObject json;
try {
json = new JSONObject(shelf);
} catch (JSONException e) {
throw new IllegalArgumentException("Invalid JSON Payload: " + shelf, e);
}
selectedShelf= json.getLong("shelf");
logger.debug(selectedShelf+"");
logger.info("Json Payload = " + json);
}
, but at the end of my java method, I see the following error:
"org.thymeleaf.exceptions.TemplateInputException: Error resolving template "shelf", template might not exist or might not be accessible by any of the configured Template Resolvers
I don't have a template for /shelf and I don't want to have it as I just want to pass a value to my class. How can I resolve this problem ?
@ResponseStatus(value = HttpStatus.OK)to the method. i think what happend here is that spring is trying to find a view based on the request url. adding the above annotation should force spring to just send an empty response with the specified status code.