我正在将应用程序从struts 1转换为Spring MVC,并且尝试使用导入org.apache.struts.config.MessageResourcesConfig和org.apache.struts.util进行Java代码处理。 MessageResources。在spring-servlet.xml文件中,我添加了包含消息资源属性文件的行,但是我不再使用struts 1库。我将如何转换这部分代码?
在整个应用程序中都很好用,例如这样的地方:
this.config = new MessageResourcesConfig();
this.config.setParameter("path that was used here was set in the spring-servlet configuration file");
this.resources = MessageResources.getMessageResources(this.config.getParameter());
我将重构您使用java.util.ResourceBundle
加载资源的方式>
// load resourcebundle.properties bundle = ResourceBundle.getBundle("resourcebundle");
然后您可以使用]获得值>
String val = bundle.getString(key);