File upload 当达到文件大小限制时,如何在屏幕上显示错误消息?

File upload 当达到文件大小限制时,如何在屏幕上显示错误消息?,file-upload,liferay,filesize,File Upload,Liferay,Filesize,如果我试图上传超过限制大小的文件。。 屏幕上没有显示错误消息,但我确实在日志上发现了一条错误消息,上面说: 03:24:20,890 ERROR [UploadServletRequestImpl:101] org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (220546593) exceeds the config

如果我试图上传超过限制大小的文件。。 屏幕上没有显示错误消息,但我确实在日志上发现了一条错误消息,上面说:

 03:24:20,890 ERROR [UploadServletRequestImpl:101] org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (220546593) exceeds the configured maximum (104857600)
org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (220546593) exceeds the configured maximum (104857600)
我想在我的屏幕上特别显示一条错误消息:“您已达到10mb的最大大小。”


谢谢。

在动作类中,您将添加错误键和请求对象,如下所示

SessionErrors.add(actionRequest, "your-error");
在JSP中,您将添加:

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<liferay-ui:error key="your-error" message="Your error message goes here!" />
在jsp中

<liferay-ui:error exception="<%= SomeException.class %>" message="This is your Error" />

参考链接:

您正在使用哪个liferay portlet?很抱歉,您能给我一些portlet的示例吗..我对这个很陌生..事实上,我已经在服务器管理>文件上载>最大文件大小中编辑了最大文件大小…Document and Media portlet是您可以上载文档的
<liferay-ui:error exception="<%= SomeException.class %>" message="This is your Error" />