HTTP method GET is not supported by this URLITeye - AG环亚娱乐集团

HTTP method GET is not supported by this URLITeye

2019-01-13 15:40:43 | 作者: 凯时 | 标签: 暗码,一个,正确 | 浏览: 2047

HTTP method POST is not supported by this URL 我做了一个登录页面 用servlet来处理暗码验证 servlet是要衔接数据库的 可是rn页面一提交之后就rn报错HTTP method POST is not supported by this URLrnrnpackage my;rnrnimport java.io.IOException;rnimport java.io.PrintWriter;rnimport java.sql.Connection;rnimport java.sql.PreparedStatement;rnimport java.sql.ResultSet;rnimport java.sql.SQLException;rnimport java.sql.Statement;rnrnimport javax.servlet.ServletConfig;rnimport javax.servlet.ServletContext;rnimport javax.servlet.ServletException;rnimport javax.servlet.ServletRequest;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnimport javax.servlet.http.HttpSession;rnrnpublic class Loginservlet extends HttpServlet rnrn rn Connection conn;rn Statement stmt;rn PreparedStatement pstmt;rn ResultSet rst;rn rn /**rn * Constructor of the object.rn */rn public Loginservlet() rn super();rn rnrn /**rn * Destruction of the servlet. rn */rn public void destroy() rn super.destroy(); // Just puts destroy string in logrn // Put your code herern rnrn /**rn * The doGet method of the servlet. rn *rn * This method is called when a form has its tag value method equals to get.rn * rn * @param request the request send by the client to the serverrn * @param response the response send by the server to the clientrn * @throws ServletException if an error occurredrn * @throws IOException if an error occurredrn */rn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rnrn doPost(request,response);rn rnrn rn public void doPost(HttpServletRequest request, HttpServletResponse response, ServletRequest session)rn throws ServletException, IOException rnrn ServletContext application=getServletContext() ;rn ServletConfig config=getServletConfig() ;rn response.setContentType( text/html;charset=utf-8 rn PrintWriter out=response.getWriter(); rn // HttpSession session =request.getSession();rn request.setCharacterEncoding( utf-8 rn System.out.println( hello6 rn String userid = request.getParameter( userid rn String password = request.getParameter( password rn System.out.println( hello7 rn rn tryrn System.out.println( hello7 rn rst = stmt.executeQuery( select * from userinfo where userid= +userid+ rn rn if(rst.next())rn rn if(rst.getString( password ).equals(password))rn rn response.sendRedirect( ./index.jsp rn System.out.println( 暗码正确 rn session.setAttribute( user ,userid);rn rn rn elsern response.sendRedirect( login.jsp?info=1 rn System.out.println( 暗码正确 rn rn rn elsern rn response.sendRedirect( login.jsp?info=1 rn System.out.println( 暗码正确 rn rn rn catch(Exception e)rn rn e.printStackTrace();rn rn finallyrn rn if(rst!=null)rn rn try rst.close();catch(Exception e)rn e.printStackTrace();rn rn if(stmt!=null)rn rn try stmt.close();catch(Exception e)e.printStackTrace();rn rn if(conn!=null)rn rn try conn.close();rn catch(Exception e)rn e.printStackTrace();rn rn rn rn rnrn rn public void init() throws ServletException rn // Put your code herern DB db = new DB();rn System.out.println( hello1 rn conn =db.getConn();rn try rn System.out.println( hello2 rn stmt = conn.createStatement() ;rn System.out.println( hello3 rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn System.out.println( hello4 rn rn rn rnrnrnrn程序会输出rnhello1rnhello2rnhello3rnrn也就是有履行这人函数init() DB是一个创立衔接 DB db = new DB();的一个类rnrn各位帮一下忙啊 rnrn

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表AG环亚娱乐集团立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章