I have a JSP page that makes an ajax post to a Java spring controller. However, whenever I make the post, I am getting a 415 Unsupported Media Type error. Since I'm fairly new to Spring MVC, I'm not sure if the error is due to my response type or request type. My ajax looks like:
$.ajax({
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
type: "POST",
url: "validateRedirect",
context:document.body,
contentType:"application/json",
data:JSON.stringify(validateObject),
dataType:"json"
});
With my request mapping looking like:
@RequestMapping(value = "/validateRedirect", method = {RequestMethod.POST}, headers="Content-Type=application/json")
public ResponseEntity<String> callToValidate(HttpServletRequest servletRequest, HttpServletResponse servletResponse, @RequestBody ValidateObj validateObject)
Even when I try to make a post from Postman, I get the same error, so I'm thinking it's something to do with my response
<mvc:annotation-driven/>in my servlet.xml