[英]Is there a jQuery datatables - spring integration example
I would like to make my jQuery to Spring Controller integration very smooth such that I can have a controller method defined as such: 我想使我的jQuery与Spring Controller集成非常顺利,这样我就可以定义一个controller方法:
@Controller
@RequestMapping(value="/api")
public class DataTablesController {
//could be GET or POST
@RequestMapping(method= RequestMethod.POST)
public @ResponseBody
DataTablesResponse getData(@RequestBody DataTablesRequest dtReq, HttpServletResponse respnose) {
.....
DataTablesResponse response = new DataTablesResponse(dtReq.getEcho());
.....
return response;
}
}
Is there an example of such an implementation that I can find somewhere? 我可以在某处找到这种实现的示例吗? I have scoured google and this forum, but could not find anything close to this.
我已经搜寻过Google和这个论坛,但是找不到与此类似的东西。
I was looking for the same thing and found this on github: https://github.com/yellowtrolley/RooDataTablesHibernate 我正在寻找相同的东西,并在github上找到了它: https : //github.com/yellowtrolley/RooDataTablesHibernate
It looks pretty promising. 看起来很有希望。
Example: 例:
@RestController
public class UserRestController {
@Autowired
private UserRepository userRepository;
@JsonView(DataTablesOutput.View.class)
@RequestMapping(value = "/data/users", method = RequestMethod.GET)
public DataTablesOutput<User> getUsers(@Valid DataTablesInput input) {
return userRepository.findAll(input);
}
}
Maven artifact: Maven工件:
<dependency>
<groupId>com.github.darrachequesne</groupId>
<artifactId>spring-data-jpa-datatables</artifactId>
<version>2.3</version>
</dependency>
I created a class called TableData which I return in the @ResponseBody: 我创建了一个名为TableData的类,该类在@ResponseBody中返回:
public class TableData {
/**
* @param data The array of data
*/
public TableData(List data) {
this.data = data;
}
/**
* The data. This will be converted to a JSON array of "data: ".
*/
private List data;
/** Values for server side processing */
private Integer draw;
private Long recordsTotal;
private Long recordsFiltered;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.