javaee论坛

普通会员

225648

帖子

352

回复

366

积分

楼主
发表于 2017-07-29 07:47:03 | 查看: 519 | 回复: 0
本文为服务器端架构,讲之前,友情提示:记得将客户端 的  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;	}

源代码传送门:点击打开链接


您需要登录后才可以回帖 登录 | 立即注册

触屏版| 电脑版

技术支持 历史网 V2.0 © 2016-2017