如何覆盖 struts.messages.error.file.too.large 属性 [英] How to override struts.messages.error.file.too.large property

查看:21
本文介绍了如何覆盖 struts.messages.error.file.too.large 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Struts2 fileUpload 拦截器来上传文件.我已经配置了 maxSize,允许的 contentTypes ... props 等.但是当用户违反 maxSize ... Struts2 显示错误消息,这是很长的字符串 ...

I am using Struts2 fileUpload interceptor to upload the files. I have configured the maxSize, allowed contentTypes ... props etc. But when user violate the maxSize ... Struts2 display error message which is very long string ...

我想更改消息字符串,即如何覆盖 struts.messages.error.file.too.large ... 有什么想法吗?

I want to change the message string i.e. how I can override struts.messages.error.file.too.large ... any idea?

谢谢!

推荐答案

您可以在现有的消息资源 .properties 文件中为类或全局定义自定义错误消息:

You can define the custom error messages in your existing message resource .properties file(s) for the class or globally:

struts.messages.error.uploading=Upload error.
struts.messages.error.file.too.large=Uploaded file was too large.
struts.messages.error.content.type.not.allowed=File type is not allowed.
struts.messages.error.file.extension.not.allowed=File extension is not allowed.

如果您当前没有使用 .properties 文件来存储您的文本,文档中有一个很好的部分关于使用和配置 消息资源文件.

If you're not currently using .properties files to store your text, the docs have a good section on using and configuring Message Resource Files.

这篇关于如何覆盖 struts.messages.error.file.too.large 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆