如何从struts中读取struts-config.xml中配置的message-resource文件

1.Struts provide a methods in the Action class to get the locale and the resources
getLocale(request) and getResources(request)

2.从servlet的上下文中获取
MessageResources resources = (MessageResources)getServlet().getServletContext().getAttribute(bundle);
String message = resources.getMessage(locale, key);


参考: Load Message Resources from Struts Action

猜你喜欢

转载自herry.iteye.com/blog/1766039