这是我的 struts.xml 的一部分:
<constant name="struts.custom.i18n.resources" value="global" />
and
<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)
我想做的是让它显示“上传的文件太大”而不是上面的消息。有什么简单的方法可以做到这一点?
EDIT 1:
我使用的是struts版本2.1.8.1
EDIT 2:
另一件事是,当我添加:
<result name="input" type="redirect">error</result>
到我的 struts.xml 则根本没有错误显示。这是什么原因呢?
呵呵,你这个问题还真被问到了。看起来很简单。
看看这里的例子:http://struts2-by-ash.blogspot.com/2012/06/override-struts-2-messages.html http://struts2-by-ash.blogspot.com/2012/06/override-struts-2-messages.html
best, j
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)