Spring MVC: get a spring message resource programmatically
March 16, 2012 12:35:26 Last update: March 16, 2012 12:35:26
To programmatically resolve a spring message:
// import org.springframework.web.servlet.support.RequestContextUtils; // import org.springframework.web.context.WebApplicationContext; WebApplicationContext appCtx = RequestContextUtils.getWebApplicationContext(request); String theMessage = appCtx.getMessage( "message.key", arguments, // Object[] RequestContextUtils.getLocale(request) )