弹簧迁移消息资源的支柱

问题描述 投票:0回答:1

我正在将应用程序从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 spring jsp web-applications struts
1个回答
1
投票

我将重构您使用java.util.ResourceBundle加载资源的方式>

// load resourcebundle.properties
bundle = ResourceBundle.getBundle("resourcebundle");

然后您可以使用]获得值>

String val = bundle.getString(key);
© www.soinside.com 2019 - 2024. All rights reserved.