1

我正在使用服务器端验证进行登录页面,我应该在 prashanth 和 sharma 的位置填写什么?

package web.com;


@WebServlet(name="AndroidResponse", urlPatterns={"/androidres.do"})
public class AndroidResponse extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        PrintWriter out=response.getWriter();
        String un,pw;
        un=request.getParameter("username");
        pw=request.getParameter("password");
        if(un.equalsIgnoreCase("prashant") && pw.equals("sharma"))
            out.print(1);
        else
            out.print(0);
    }
}
4

1 回答 1

0

你必须这样做。该方法request.getParameter("username")给出了 ua 对象,你必须向下转换它的字符串。希望这对你有用。

 String username = (String)request.getParameter("username");
 String password = (String)request.getParameter("password");
于 2013-03-22T10:17:04.317 回答