gpt4 book ai didi

java - HTTP 状态 405 - 在 glassfish 服务器上

转载 作者:行者123 更新时间:2023-12-02 11:21:41 25 4
gpt4 key购买 nike

我正在使用 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 状态 405 - 此 URL 不支持 HTTP 方法 POST
每当我提交表单时,请输入状态报告

最佳答案

试试这个

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//handle request
}

您应该更改方法参数顺序

关于java - HTTP 状态 405 - 在 glassfish 服务器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49875463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com