我想將表上的數據傳遞給servlet。我嘗試了一種方法,當iItry傳遞給servlet時,我能夠獲取數據,但我無法從request.getParameter("forecastdata");
獲取空值的數據。請告訴什麼是我的代碼中的錯誤 ArrayToJson無法將數據從javascript傳遞給json
@WebServlet("/arrayToJson/*")
public class ArrayToJson extends HttpServlet {
@Override
protected void doPost(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException,
IOException {
StringBuffer jb = new StringBuffer();
String line = null;
request.getParameter("forecastdata");
;
}
}
的JavaScript
$("#divButtons").find(".btnSubmit").click(function() {
console.log($container.data('handsontable').getData());
var forecast=$container.data('handsontable').getData()
$.ajax({
url: "/Pj_IFRS_P5/arrayToJson",
data: {
forecastdata: forecast
}, //returns all cells' data
dataType: 'json',
type: 'POST',
success: function (data) {
if (data.result === 'ok') {
console.log('Data saved');
} else {
console.log('Save error');
}
},
error: function() {
console.log('Save error. POST method is not allowed on GitHub Pages. Run this example on your own server to see the success message.');
}
});
});
$("#handsontable").handsontable(config);
});
它爲此行打印了什麼「console.log($ container.data('handsontable')。getData());」 –
它打印的數據值 –
我現在的問題是我如何有條件地禁止行handsontable –