Struts 1:在哪里放置消息资源的属性文件

发布于 2024-10-21 22:14:23 字数 1553 浏览 1 评论 0原文

我从 struts 收到 NullPointerError,相应的堆栈跟踪如下:

PropertyMessa W org.apache.struts.util.PropertyMessageResources loadLocale   Resource org/apache/struts/action/ActionResources_en_US.properties Not Found.
PropertyMessa W org.apache.struts.util.PropertyMessageResources loadLocale   Resource org/apache/struts/action/ActionResources_en.properties Not Found.
RequestUtils  E org.apache.struts.util.RequestUtils createActionForm Error creating form bean of class com.teig.territorymaint.web.TerritoryForm
at org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:289)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:254)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:208)
at org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor.java:319)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:192)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

我不明白为什么 Struts 试图从 apache struts 包路径获取属性文件,我怀疑我的 struts 配置是错误的:

<message-resources parameter="ApplicationResources" null="false" />

然后,我修改了消息资源标签,得到了同样的错误:

<message-resources parameter="myPackagePath.ApplicationResources" null="false" />

我做错了什么?提前致谢。

I am getting a NullPointerError from struts, and the corresponding stack trace is the following:

PropertyMessa W org.apache.struts.util.PropertyMessageResources loadLocale   Resource org/apache/struts/action/ActionResources_en_US.properties Not Found.
PropertyMessa W org.apache.struts.util.PropertyMessageResources loadLocale   Resource org/apache/struts/action/ActionResources_en.properties Not Found.
RequestUtils  E org.apache.struts.util.RequestUtils createActionForm Error creating form bean of class com.teig.territorymaint.web.TerritoryForm
at org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:289)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:254)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:208)
at org.apache.struts.action.RequestProcessor.processActionForm(RequestProcessor.java:319)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:192)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

I don't understand why Struts is trying to fetch the properties file from the apache struts package path, and I suspected that my struts configuration is wrong:

<message-resources parameter="ApplicationResources" null="false" />

Then, I modified the message resources tag, and I got the same error:

<message-resources parameter="myPackagePath.ApplicationResources" null="false" />

What am I doing wrong? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枯叶蝶 2024-10-28 22:14:23

约恩是正确的;问题不是由缺少资源文件引起的,而是我在struts配置文件中的form-b​​ean type属性不正确造成的

  <form-bean name="territoryAddForm"
         type="com.teig.territorymaint.web.forms.TerritoryForm">
         <!-- package path was incorrect -->
</form-bean>

Jörn is correct; the problem was not caused by the missing resource files, but my incorrect form-bean type attribute in struts configuration file

  <form-bean name="territoryAddForm"
         type="com.teig.territorymaint.web.forms.TerritoryForm">
         <!-- package path was incorrect -->
</form-bean>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文