@At("/html4")
@AdaptBy(type=UploadAdaptor.class, args="ioc:upload")
//上传
public Object html4(@Param("f")TempFile tmpFile, AdaptorErrorContext errCtx) {
if (errCtx != null) {
log.info(errCtx.getAdaptorErr());
return false;
}
if (tmpFile == null || tmpFile.getFile().length() < 1024) {
return false;
}
log.debug(tmpFile.getMeta().getFileLocalName());
File file = tmpFile.getFile();
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
System.out.println(Files.getSuffixName(file).toLowerCase());
System.out.println(webPath(uuid));
String dest = webPath(uuid) + "." + Files.getSuffixName(file).toLowerCase();
System.out.println();
String smallPath = webPath(uuid) + Files.getSuffixName(file).toLowerCase();
try {
Images.zoomScale(file, new File(smallPath), 128, 128, Color.BLACK);
file.renameTo(new File(dest));
} catch (Throwable e) {
log.info(e);
return false;
}
return "../upload/images/" + uuid + "."+ Files.getSuffixName(file).toLowerCase();
}
public String webPath(String path) {
return Mvcs.getServletContext().getRealPath("/upload/images/") + path;
}
现在上传成功是返回一个图片路径,我想直接返回上传的图片到页面怎么改?