67,513
社区成员
发帖
与我相关
我的任务
分享
private String errorMsg;
private boolean success; //
或“false”
public class JsonFileUploadInterceptor extends FileUploadInterceptor
{
private Log log = LogFactory.getLog(this.getClass());
@Override
public String intercept(ActionInvocation invocation) throws Exception
{
log.debug("json file upload interceptor start ....");
String result = "";
try
{
result = super.intercept(invocation);
if ("input".equalsIgnoreCase(result))
{
BasicAction action = (BasicAction) invocation.getAction();
action.setSuccess(false);
action.setErrorMsg("上传失败");
log.debug("json file upload interceptor end ....");
return result;
}
}
catch (Exception e)
{
BasicAction action = (BasicAction) invocation.getAction();
action.setSuccess(false);
//如果action中具有actionError,表示上传文件超过struts默认的最大大小maxSize,
if(action.hasActionErrors() == true)
{
action.setErrorMsg(action.getText(ErrorMsgConstant.ERROR_UPLOADFILE_FILE_TOO_LARGE));
return "success";
}
else
{
return "input";
}
}
log.debug("json file upload interceptor end ....");
return result;
}
result = super.intercept(invocation);