当我使用Netbeans和互联网时,我一直收到此错误。
“HTTP状态405 - 此URL不支持HTTP方法POST”
我不知道这里发生了什么,如果有人能帮助我,我会很高兴。这是我得到的。它是这样的。
package servlets;
import business.*;
import business.User;
import data.*;
import data.UserIO;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import static javax.ws.rs.client.Entity.html;
/**
* FFilename: AddDisplayInput.java Date: August September 23, 2014 Author Russell Lindsey
*/
public class AddDisplayInput extends HttpServlet {
/**
* Processes requests for both HTTP <code>POST</code
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOExceptin if an I/O errr occurs
*/
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// the next 7 lines are the same as in the display_email_entry.jsp file
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String emailAddress = request.getParameter("emailAddress");
User user = new User(firstName, lastName, emailAddress);
ServletContext sc = this.getServletContext();
String path =sc.getRealPath("/Web-INF/EmailList.txt");
UserIO.add(user, path);
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use the following sample code. */
out.println("<!DOCTYPE html>\n");
out.println("<html>\n");
out.println("<head>\n");
out.println("<title>Servlet AddDisplayInput</title>\n");
out.println("</head>");
out.println(" <body\n" +
" <h1>Thanks for Joining Russell Lindsey's email list</h1>\n" +
" <p>\n" +
" Here is the information you entered</p>\n" +
" </p>\n" +
" <p>\n" +
" First Name: " + user.getFirstName() +" \n" +
" </p>\n" +
" <p>\n" +
" Last Name: " + user.getLastName() +" \n" +
" </p>\n" +
" <p>\n" +
" Email Address: " + user.getEmailAddress() + " \n" +
" </p>\n" +
"\n" +
" </p>\n" +
" Click this button to return to the email entry page:\n" +
" </p>\n" +
" <form action=\"index.html\" method=\"post\">\n" +
" <input type=\"submit\" value=\"Return to input\"/>\n" +
" </form>\n" +
" \n" +
"</body>");
out.println("</html>");
}
}
}<b>
我不知道我在这里写错了什么。任何人都可以帮助我,在这里,给出一些关于该做什么的指示?