简体   繁体   中英

How to get parameters from the method and display a matrix in the HTML through JSP?

The JSP have a method that creates a matrix:

<%!
int[][] rndMatrix(int M, int N) {
Random rnd = new Random();
int matrix[][] = new int[M][N];
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
  matrix[i][j] = 1;
}
matrix[i][rnd.nextInt(N)] = 0;
}
%>

I can not figure out how to get the parameters of the method itself, which would have to ask them and to bring in html.

If I understand you correctly, you just want to access the parameters you pass to the method. In that case, you already have that in the return value

M == return_matrix.length

N == return_matrix[0].length

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM