You can inject MessageSource
to your controller and return a String
message from that controller. Simply:
@Autowired
MessageSource messageSource;
@RequestMapping(value="/myajax", method=RequestMethod.GET)
@ResponseBody
public String getMyAjaxMessage() {
return messageSource.getMessage(..); // use your proper arguments or extract from request parameters
}
javascript (assuming jquery is used):
$.get('/myajax', function(data){
// do whatever you want with data (will contain your message)
});
Here are docs: