Passing Parameter in URL to DataTables controllers
Passing Parameter in URL to DataTables controllers
I'm working on a server side processing DataTables (with Spring MVC), the following works as expected:
URL: http://localhost:8080/directory.html
datatable.js
$(document).ready( function () {
var table = $('#directoryTable').DataTable({
serverSide: true,
ajax: {
"url": "/employees",
.....
}
});
controller:
@RestController
public class EmployeeRestController {
@RequestMapping(value = "/employees", method = RequestMethod.POST)
@ResponseBody
public String listEmployeePaginated(HttpServletRequest request, HttpServletResponse response, Model model) {
.....
}
}
Questions: How to process the same URL with an added parameter:
http://localhost:8080/directory.html?affiliation=student
I can't figure out how to pass the parameter (affiliation=student) to datatable.js to be received and processed by the controller?
New to Spring MVC and DataTables. Any help is greatly appreciated. Thanks!
This question has an accepted answers - jump to answer
Answers
I can't help you with the Spring part, but if you want to pass a query string along in an Ajax request you can use
ajax.data
along with window.location'ssearch
parameter.Allan
Thanks for the hints! Using your suggestions solved the problem that I've been struggling with!