我有Java Spring Boot应用程序。在控制台json中输入数据(但顺序错误?),当我将其转换为String时,我可以获取它,但无法返回JSONObject,POSTman显示{“ empty”:false}
我的控制器包com.example.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.dao.SeriaDao;
import com.example.model.Seria;
@RestController
public class WebController {
@Autowired
SeriaDao sed;
@GetMapping("/tabelka")
public List<Seria> showTable()
{
return sed.findAll();
}
@GetMapping("/pgTabelka")
public JSONObject pgTable(HttpServletRequest request)
{
int draw = 0;
int start = 0;
int length = 10;
JSONObject json = new JSONObject();
if(request.getParameter("draw")!=null)
draw = Integer.parseInt(request.getParameter("draw"));
if(request.getParameter("start")!=null)
start = Integer.parseInt(request.getParameter("start"));
if(request.getParameter("length")!=null)
length = Integer.parseInt(request.getParameter("length"));
int totalRecords = sed.recordsTotal();
List<Seria> serie …Run Code Online (Sandbox Code Playgroud) 我有带有客户端分页的Spring REST应用程序,DataTables默认使用它,并且一切正常。现在,我需要将其更改为服务器端分页,但我有问题,因为不知道如何从DataTables中获取客户端想要查看的页码信息。我在DT手册中找不到任何有用的内容。