索引.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Cars Selling</title>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="listCarsSelling.js"></script>
</head>
<body>
<h2>Cars Selling List</h2>
<table id="table-content">
<thead>
<tr>
<td>code</td>
<td>manufacturer</td>
<td>model</td>
<td>color</td>
<td>transmission</td>
<td>body_type</td>
<td>price</td>
</tr>
</thead>
</table>
</body>
</html>
listCarsSelling.js
$(document).ready(function(){
$.ajax(
{
type: "GET",
url: "http://localhost:8080/ListCarsSelling",
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
success: function(data){
for (var i=0; i<data.length; i ) {
var row = $('<tr><td>' data[i].code '</td><td>' data[i].manufacturer
'</td><td>' data[i].model '</td><td>' data[i].color '</td><td>'
data[i].transmission '</td><td>' data[i].body_type '</td><td>'
data[i].price '</td></tr>');
$('#table-content').append(row);
}
},
error: function(msg){
allert(msg.responseText);
}
});
})
在鏈接“http://localhost:8080/”上參考錯誤“404”的照片: 在此處輸入影像描述
我希望我的資料庫中的資料在我進入主頁時立即顯示。我怎樣才能做到這一點?我還想指出,我連接到資料庫沒有問題,因為在開發 rest 時我能夠提取 json 資料。我現在需要以某種方式顯示它們..
uj5u.com熱心網友回復:
呃,這個問題很痛苦,司空見慣。專案結構不正確。應用程式檔案在另一個包中,它應該首先如下所示。 我的天啊
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/360652.html
