下面的三个判断能不能用for循环简化一下
if (from1.getuploadfile1().getFileSize() != 0) {
System.out.println("1234");
str = com.getpicturename(from1.getuploadfile1(), path);
strpath.append(str + ",");
} if (from1.getuploadfile2().getFileSize() != 0) {
System.out.println("1234");
str = com.getpicturename(from1.getuploadfile2(), path);
strpath.append(str + ",");
} if (from1.getuploadfile3().getFileSize() != 0) {
System.out.println("1234");
str = com.getpicturename(from1.getuploadfile3(), path);
strpath.append(str + ",");
}
if (from1.getuploadfile1().getFileSize() != 0) {
System.out.println("1234");
str = com.getpicturename(from1.getuploadfile1(), path);
strpath.append(str + ",");
} if (from1.getuploadfile2().getFileSize() != 0) {
System.out.println("1234");
str = com.getpicturename(from1.getuploadfile2(), path);
strpath.append(str + ",");
} if (from1.getuploadfile3().getFileSize() != 0) {
System.out.println("1234");
str = com.getpicturename(from1.getuploadfile3(), path);
strpath.append(str + ",");
}
设计成getuploadfile(parameter), 也许这个地方就会很简洁。令,不知道java中有没有类似javascript的eval,呵呵。
for(int i=0;i<3;i++)
{
if (uploadfile[i].getFileSize()!= 0) {
System.out.println("1234");
str = com.getpicturename(file[i], path);
strpath.append(str + ",");
}
}
只是个思路,我写的不一定对。