javascript - Form sending data to controller once, then it doesn't work -


i have jsp board play tic tac toe. , after each click on send clicked field spring controller. find best move computer , display board moves of me , of computer. problem after first move, clicking on field doesn't anything, script works once. , changing parameters in url manually change position of move, doesn't make one.

code of form board ("game.jsp"):

%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>  <html> <head>     <title>game</title> </head> <body> <script>     function redirect(x, y) {         window.location = "http://localhost:8080/tasknine/move?x=" + x + "&y=" + y;     } </script>     <form name="tic" method="post" accept-charset=utf-8>     <input type="button" name="sqr1" class="tictac" value="${board[0][0]}" onclick="if(document.tic.sqr1.value == '') {document.tic.sqr1.value = 'x';redirect(0, 0); }">     <input type="button" name="sqr2" class="tictac" value="${board[0][1]}" onclick="if(document.tic.sqr2.value == '') {document.tic.sqr2.value = 'x';redirect(0, 1); }">     <input type="button" name="sqr3" class="tictac" value="${board[0][2]}" onclick="if(document.tic.sqr3.value == '') {document.tic.sqr3.value = 'x';redirect(0, 2); }"> <br />     <input type="button" name="sqr4" class="tictac" value="${board[1][0]}" onclick="if(document.tic.sqr4.value == '') {document.tic.sqr4.value = 'x';redirect(1, 0); }">     <input type="button" name="sqr5" class="tictac" value="${board[1][1]}" onclick="if(document.tic.sqr5.value == '') {document.tic.sqr5.value = 'x';redirect(1, 1); }">     <input type="button" name="sqr6" class="tictac" value="${board[1][2]}" onclick="if(document.tic.sqr6.value == '') {document.tic.sqr6.value = 'x';redirect(1, 2); }"> <br />     <input type="button" name="sqr7" class="tictac" value="${board[2][0]}" onclick="if(document.tic.sqr7.value == '') {document.tic.sqr7.value = 'x';redirect(2, 0); }">     <input type="button" name="sqr8" class="tictac" value="${board[2][1]}" onclick="if(document.tic.sqr8.value == '') {document.tic.sqr8.value = 'x';redirect(2, 1); }">     <input type="button" name="sqr9" class="tictac" value="${board[2][2]}" onclick="if(document.tic.sqr9.value == '') {document.tic.sqr9.value = 'x';redirect(2, 2); }"> <br />     </form> </body> </html> 

and here controller snippet:

@requestmapping(value = "/move", method = requestmethod.get) public string fieldmove(@requestparam("x") int x, @requestparam("y") int y, modelmap model) {      gameservice.move(x, y, model);     return "game"; } 

the name of requestparam has match name of input:

@requestmapping(value = "/move", method = requestmethod.get) public string fieldmove(@requestparam("sqr1") int sqr1, @requestparam("sqr2") int sqr1, ..., modelmap model) {  // return "game"; 

}


Comments