您的位置:首页 > 理论基础 > 计算机网络

登录界面 Android简单http get请求(含服务器端)三

2015-03-10 16:52 330 查看
本文为服务器端架构,讲之前,友情提示:记得将客户端 的 Internet权限打开。

客户端采用servlet 3.0搭建不需要再web.xml中进行配置

本文做的功能简单获取到客户端发送过来的username和password即可。

项目结构图:






代码如下get 方法放到post方法处理:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		

		
		this.doPost(request, response);
	}

	/**
	 * @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");
		String name=request.getParameter("username");
		String password=request.getParameter("password");
	    
		System.out.println("username--->"+name);
		System.out.println("password---->"+password);
		return;
	}

源代码传送门:点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: