找不到从 HttpRequest 获取参数值的正确方法:
这是我的 JQuery 文件:
$(document).ready(function() {
var currBoard;
var currCell;
$(".cell").click(function() {
Cardboard = $ (this). attr ('name');
currCell = $(this).attr('id');
$.get('InGameServlet', function(responseText) {
$("#"+currCell).text(responseText);
alert("cell num:" + currCell + " Board: " + currBoard);
});
});
});
这是我的 Servlet:
@WebServlet(name = "InGameServlet", urlPatterns = {"/InGameServlet"})
public class InGameServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
printSign(request.getParameter("currBoard"), request.getParameter("currCell"), response);
}
在调试模式下,我看到我从请求中获得的值是 NULL!
我究竟做错了什么?