当前位置: 代码迷 >> Java Web开发 >> 求教 Servlet
  详细解决方案

求教 Servlet

热度:411   发布时间:2013-04-26 09:59:03.0
求教 Servlet
老是Servlet接收不到 ,老是出错,求大神指教一下。

HTML部分:
<form action="UserServlet" method="post">
<div class="style1">用户名:<input type="text"width="150px" height="15px" id="user" name="userId"></div>
<div class="style1">密&nbsp;&nbsp;码:
  <input type="text"width="150px" height="15px" id="password"  name="password"></div>
   <div>
      <input type="checkbox" id="save" />
      
      <div> <input type="submit"  value="登录" />

</form>


servlet 部分://名字是UserServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        PrintWriter out=response.getWriter();
        String userId = request.getParameter("userId");
        String usePassword = request.getParameter("password");
        //userDAO ud=new userDAO();
        //ud.setUserInfo(userId, usePassword);
        //System.out.println();
        
        System.out.println(request.getParameter("userId"));
        out.println(userId+usePassword);
        out.flush();
    }

}


搜索更多相关主题的帖子: servlet  password  用户名  action  

----------------解决方案--------------------------------------------------------
是报的什么错误呢,最好可以把错误也帖出来
如果说是找不见servlet的话,可以变为<form action="${pageContext.request.contextPath}/UserServlet" method="post">
----------------解决方案--------------------------------------------------------
  相关解决方案