开发者

getJSON data for Java stripes

When performing a getJSON function, and I want to send some data to the server (I'm using a ja开发者_StackOverflow中文版va Stripes framework), I was jut wondering, what datatype will it be?

e.g.

$.getJSON("/tictactoe/get_next_move",
   {board: displayedBoardArray},
   function(data) {
   var json = data;
}

What is the type of board if I want to retrieve it? displayedBoardArray is a var Array type. After retrieving the board type and printing it out like this:

private String[] board;

public String[] getBoard(){
    return board;
}

public void setBoard(String[]board){
    this.board = board;
}

...
System.out.println("board: " +board); //This retrieved a null
...

Is String[] a wrong datatype?


I'm going to chime in only because better people than me have not yet. Nothing gets good answers quicker than someone trying to one-up someone else. ;-)

What form does displayedBoardArray take? If it's actually an object containing key:value pairs, it should come into the server as a series of GET parameters and values. If it's just a raw JavaScript array, I don't think you can do that.

In general, though, once you are sending valid data to the server, it will come in as GET parameter(s) which you will grab using some sort of method. I couldn't say if your Stripes method is doing that. Again, generally speaking, you can theoretically have a method that will create an array, or a method that will create a string (with comma separations or similar). I guess it depends on the method that's grabbing the GET parameter values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜