【发布时间】:2012-06-22 10:23:12
【问题描述】:
这是我的 struts.xml 的一部分:
<constant name="struts.custom.i18n.resources" value="global" />
和
<action name="picture_save" method="pictureSave" class="PictureActionBean">
<interceptor-ref name="fileUpload">
<param name="maximumSize">
2097152
</param>
<param name="allowedTypes">
image/bmp,image/gif,image/jpeg,image/jpg,image/png
</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success" type="redirect">picture</result>
<result name="error">error</result>
</action>
我的 global.properties 文件直接存储在 src/ 中,其中包含以下内容:
struts.messages.error.uploading=Upload failed
struts.messages.error.file.too.large=Upload file is too large
struts.messages.error.content.type.not.allowed=Wrong file type uploaded
这是我在 jsp 中显示错误的方式:
<s:fielderror />
目前,当我上传一个太大的文件时,例如,我收到错误:
请求被拒绝,因为它的大小 (6561343) 超过 配置最大值 (2097152)
我想要做的是让它说“上传的文件太大”而不是上面的消息。有什么简单的方法可以做到这一点?
编辑 1:
我正在使用 struts 版本 2.1.8.1
编辑 2:
另一件事是,当我添加:
<result name="input" type="redirect">error</result>
到我的 struts.xml 然后根本没有错误显示。这是什么原因?
【问题讨论】:
-
到目前为止我还没有取得任何成功。我在网上搜索并阅读了文档:struts.apache.org/2.1.8.1/docs/message-resource-files.html
-
我刚试过这个,但没有运气:blog.bielu.com/2008/09/…
-
请在帖子本身添加附加信息;这也有利于将您的问题移回问题的顶部,从而获得可见性。您使用的是什么版本的 S2?
标签: jsp error-handling struts2 messages