我是jsp的新手,我想在数组中添加图像。 代码:
<%
int row = 6;
int col = 5;
ArrayList<String> allImages = new ArrayList<String>();
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
if (i == (row - 1) && j == (col - 1))
allImages.add("no_image");
else
allImages.add("WEB-INF/car" + i + j + ".jpg");
}
}
//shuffle the list to generate random puzzle every time
Collections.shuffle(allImages);
... %>
最初,我认为插入数组的照片数量更多,随机选择了一张照片。但现在我只想在阵列中插入一张照片,但也无法看到照片的路径。我该如何解决这个问题呢? 谢谢!