I am using Spring MVC with JSON as specified in Ajax Simplification Spring 3.0 article.
After so many attempts and variations of my code depending on advice found on
Well, The answers on this page might be right but they didn't expatiate well. This is what I did
I added this to my pom.xml
org.codehaus.jackson
jackson-core-asl
1.9.8
org.codehaus.jackson
jackson-mapper-asl
1.9.8
Then I added headers to my RequestMapping like below
@RequestMapping(value="/admin/getGallery", method = RequestMethod.GET, headers={"Content-Type=application/json"})
Then in my jquery ajax I added - contentType: "application/json", so it looks like
jQuery.ajax({
type:'GET',
url:"getGallery.html",
data: "designId="+designId,
processData:false,
contentType: "application/json",
//dataType: "json",
success:function(data){
console.log(data);
},
error : function(e) {
console.log("ERROR: ", e);
},
});
Then in my servlet I added
If you have problem with util tag in your servlet just just add in the same servlet file
xmlns:util="http://www.springframework.org/schema/util"
and
xsi:schemaLocation="http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd