I am doing a web site using spring mvc framework.
I want to do a call ajax and receive a json object directly from my web controller.
What is the best way/manner/plugin to do that?
i have seen the tutorials from keith donald but, it as think a bit complicated.
thanks for any advise.
i have put the jakson json mapper in my pom file.
my controller looks like :
@RequestMapping(value = "m015", method = RequestMethod.GET)
public @ResponseBody String list(@RequestParam(value = "type", required = true) String type){
List<Mail> mails = mailService.getUserMails((Long) WebHelper.getPrincipal().getUser().getId(),type);
logger.info("yeah");
return mails.toString();
}
but i get this my javascript : [com.stunaz.domain.Mail@94e0a6a2]
my ajax call looks like :
var xhrArgs = {
url: "${ctx}/portal/mail/m015.do",
content: { type: id },
headers: {'Content-Type':'application/json'},
handleAs: 'text',
sync: true,
load: function(data) {
alert(data);
},
};
dojo.xhrGet(xhrArgs);
What did i miss please?
1 Answer