0

Basically I will not do this if I have control in the front end, but when I am using DataTable ajax feature, they post the data like this:

columns[0][data]:0
columns[0][name]:
columns[0][searchable]:true
columns[0][orderable]:true
columns[0][search][value]:
columns[0][search][regex]:false
columns[1][data]:1
columns[1][name]:
columns[1][searchable]:true
columns[1][orderable]:true
columns[1][search][value]:
columns[1][search][regex]:false
columns[2][data]:2
columns[2][name]:
columns[2][searchable]:true
columns[2][orderable]:true
columns[2][search][value]:
columns[2][search][regex]:false
columns[3][data]:3
columns[3][name]:
columns[3][searchable]:true
columns[3][orderable]:true
columns[3][search][value]:
columns[3][search][regex]:false
columns[4][data]:4
columns[4][name]:

I have 2 questions:

1) how can I retrieve the value accordingly in servlet? getParameterValues can only get 1 dimensional array, I not sure how to retrieve the example above.

2) how can I retrieve the value if I am using Spring MVC?

2
  • I'm afraid you will have to use getParameterNames() or getParameterMap() and iterate over all of the parameters above. You see request.getParameterValues() will give you multiple values if exactly the same parameter is specified more than once: given http://x.com/aaa?p=1&p=2&p=3, request.getParameterValues("p") returns ["1","2","3"] (always a string array). Commented Apr 9, 2017 at 19:34
  • @BalusC, I have asked how to do that in Spring MVC, does this stackoverflow.com/questions/6967258/… answer my question? Commented Apr 11, 2017 at 2:41

1 Answer 1

0

OK, I roughly found the answer although it is not perfect:

1) I am confused about the array parameters, in fact, posting the data as above, it is not array parameters, I can purely extract the value via string, like this.

2) For Spring MVC, I still can't find a way to convert request to an object, so for simplicity, I rather to receive the request param in @RequestParam Map<String, String> params, and iterate over each key. (Thanks @Nikos Paraskevopoulos for highlighting)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.