我正在使用netbeans IDE
这是servlet代码
public class CheckBox23 extends HttpServlet {
public void doGet(HttpServletResponse rs, HttpServletRequest rq) throws IOException, ServletException {
rs.setContentType("text/html");
PrintWriter posh = rs.getWriter();
posh.println(docType+"<html>"+"<body>"
+"<ul>"
+"<li><b>Math Flag: </b>"+rq.getParameter("maths") + "\n"+"</li>"
+"<li><b>Math Flag: </b>"+rq.getParameter("chem") + "\n"+"</li>"
+"<ul>"
+"</body>"+"</html>");
}
public void doPost(HttpServletResponse rs, HttpServletRequest rq) throws IOException, ServletException {
doGet(rq,rs);
}
}
这是html代码:
<form action="CheckBox23" method="POST" target="_blank">
<input type="checkbox" name="maths" /> Maths
<input type="checkbox" name="chem" />
Chemistry
<input type="submit" value="Select Subject" />
</form>
每当提交表单时,我都会得到
HTTP Status 405 - HTTP method POST is not supported by this URLtype Status report
最佳答案
尝试这个
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//handle request
}
您应该更改方法参数顺序
关于java - HTTP Status 405-在glassfish服务器上,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49875463/