splitimagelist.jsp
来自「实现一个网络购物」· JSP 代码 · 共 37 行
JSP
37 行
<%
if(imageId.indexOf(",")>-1) {
thisImage = imageId.substring(0,imageId.indexOf(","));
otherImages = imageId.substring(imageId.indexOf(",")+1);
if(otherImages.indexOf(",")>-1) {
nextImage = otherImages.substring(0,otherImages.indexOf(","));
otherImages = otherImages.substring(otherImages.indexOf(",")+1);
if(otherImages.indexOf(",")>-1) { // four or more images
String tPreviousImage = otherImages.substring(otherImages.lastIndexOf(",")+1);
otherImages = otherImages.substring(0,otherImages.lastIndexOf(","));
previousImage = tPreviousImage + "," + thisImage + "," + nextImage + "," + otherImages;
nextImage = nextImage + "," + otherImages + "," + tPreviousImage + "," + thisImage;
} else { // three images
previousImage = otherImages + "," + thisImage + "," + nextImage;
nextImage = nextImage + "," + otherImages + "," + thisImage;
}
} else { // two images
nextImage = otherImages + "," + thisImage;
previousImage = nextImage;
}
// count (1) number of images between offsetId and thisImage and (2) the total number of images
int comma_pos = imageId.indexOf(",",0);
while(comma_pos>-1) {
totalNumberOfImages++;
if(imageId.indexOf(offsetId,comma_pos+1)==-1) {
thisImageNumber++;
}
comma_pos = imageId.indexOf(",",comma_pos+1);
}
if(thisImageNumber==totalNumberOfImages){
thisImageNumber = 0;
}
thisImageNumber++;
} else { // one image
thisImage = imageId;
}
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?