2010-07-10 6 views
0

서블릿에서 HTML 양식의 매개 변수를 인쇄하려고하지만 서블릿에 요청에 매개 변수가 필요하지 않습니다. Servlet POST 매개 변수 null

<form method="post" action="LoginServlet" > 
    <input type="text" name="username" id="username" /><br/> 
    <input type="text" name="password" /><br/> 
    <input type="submit" /> 
</form> 

와 서블릿의의 doPost는() :

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
    System.out.println("POST"); 

    HttpSession session = request.getSession(); 
    String redirectUrl; 

    Enumeration atributes = request.getAttributeNames(); 
    while (atributes.hasMoreElements()) { 

     System.out.println((String)atributes.nextElement()+ "."); 
    } 
    String user = (String) request.getAttribute("username"); 
    String pass = (String) request.getAttribute("password"); 
    System.out.println("user:" + (String) request.getAttribute("username")); 

} 

그래서 매개 변수 및 사용자 이름 매개 변수는 NULL이 출력됩니다 않습니다.

+0

나는 이것이 부적절한 질문이라고 생각합니다. 투표를하기에 충분한 명성을 얻지 못했습니다. –

답변