Using getParameterValues and Arrays
So I getting parameters from another page, and putting them into an array, I am then taking all items in that array and running the substring
method on them:
String[] edit = request.getParameterValues("editID");
// System.out.println(edit);
String editDel = "";
if (edit != null) {
for (int i = 0; i < edit.length; ++i) {
String lf = edit[i];
editDel = lf.substring(0, lf.length() - 2);
} } else { editDel = "0"; }
// System.out.println(editDel);
So for example if I pass the params 3lf
and 12lf
from my previous page, the system 开发者_如何学编程prints [Ljava.lang.String;@520
for the variable edit
, and prints 12
for the variable editDel
. Do i need to store editDel
in an array, because I should be getting both 12
and 3
for the editDel
variable
Put the editDel print statement inside the for loop
for (int i = 0; i < edit.length; ++i) {
String lf = edit[i];
editDel = lf.substring(0, lf.length() - 2);
System.out.println(editDel);
} } else { editDel = "0"; }
精彩评论