Хорошо, я вырываю свои волосы здесь. Использование Springboot WebApp Я использую datatables для извлечения данных из базы данных mysql. Все это работает за одну вещь. Форматирование просто возвращается как один большой неформатированный большой двоичный объект, когда я go до http://localhost: 8080 / index , поэтому между страницей кода и таблицей данных jsp есть что-то не 100%. Надеюсь, что кто-то может заметить это для меня.
Контроллер
@RestController
public class HomeRestController {
@Autowired
private ServiceInterface scraperService;
@RequestMapping(path="/index", method=RequestMethod.GET)
public List<ScraperObject> getAllNonDectivatedData(){
List<ScraperObject> allNonDectivated = scraperService.getAllNonDeactivatedOnes();
return allNonDectivated;
}
}
JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring Boot + JPA + Datatables</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script>$(document).ready( function () {
var table = $('#scrapedTable').DataTable({
"sAjaxSource": "/scrapedData",
"order": [[ 0, "asc" ]],
"columns": [
{ "data": "price"},
{ "data": "description" },
{ "data": "url" }
]
})
});
</script>
</head>
<body>
<h1> Table</h1>
<table id="scrapedTable" class="display">
<!-- Header Table -->
<thead>
<tr>
<th>Price</th>
<th>Description</th>
<th>Url</th>
</tr>
</thead>
<!-- Footer Table -->
<tfoot>
<tr>
<th>Price</th>
<th>Description</th>
<th>Url</th>
</tr>
</tfoot>
</table>
</body>
</html>