需求:
解决Cannot find message resources under key org.apache.struts.action.MESSAGE错误,今天在用struts1.3做一个注册页面时出现的错误。
前提条件:
struts-config.xml 存在如下配置:
JSP的调用方式:
System.out.println(TagUtils.getInstance().message(pageContext, "
popedom", Globals.LOCALE_KEY, "username"));
出现问题:
老报异常:not find message resources under key popedom ...
解决办法:
struts-config.xml 增加配置:
该设置最好放在:</action-mappings>"放到这里"</struts-config>;
确保ApplicationResources.properties文件在你建立的WEB-INF\classes文件夹中;
问题出现原因:
struts必须有一个不带key的资源文件,
若对 applicationresource.preperties 资源文件不指定 key 的话,JSP在通过 TagUtils 类指定的 Bundle 是“
applicationresource”,而在 struts-config.xml 中的资源文件没有哪个的指定其key为“
applicationresource”,最终导致出现异常