我想使用 javascript 代码调用 Servlet doPost() 方法,但我得到 http 405(此 URL 不支持 HTTP 方法 GET)异常。
这是我的javascript代码:
url="RedirectServlet?&FD="+FD+"&TD="+TD+"&actionid="+status+"&usercode="+usercode+"&action=reports"+"";
重定向Servlet.java:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
if(action.equals("reports")){
System.out.println("inside reports");
//Getting values from Reports_arb.jsp
String Fromdate=request.getParameter("FD");
String Todate=request.getParameter("TD");
String status=request.getParameter("actionid");
String usercode=request.getParameter("usercode");
//placing given values in a session
request.setAttribute("FD", Fromdate);
request.setAttribute("TD", Todate);
request.setAttribute("actionid", status);
request.setAttribute("usercode", usercode);
//Redirecting to showReport_arb.jsp
//response.sendRedirect("showReport_arb.jsp");
request.getRequestDispatcher("showReport_arb.jsp").include(request, response);
}
}