post提交多个参数

post发起请求参数可以有很多形式,json、map,最直接的就是直接传,可一个传一个,也可以传多个。

前台请求(两个参数)

var url2 = ""
$.post(url2, {id:findPwdNumber,validNum:validNum},function (data) {
	var message_code = '<%=request.getAttribute("PwdMsg_code")%>';
	alert(message_code);
});

 后台接收

public String sendCode(String id,String validNum,HttpServletResponse response,HttpServletRequest request) throws SQLException {
		System.out.println("=================验证码接口接口开始");
		System.out.println("validNum:"+validNum);

		String rCodePwd = String.valueOf(request.getSession().getAttribute("rCode"));
		if(validNum==null||(validNum!=null&&validNum.length()==0)){

			request.setAttribute("PwdMsg_code","请输入验证码!");
			return "pages/frame/findPwd.jsp";
		}if(!validNum.equals(rCodePwd)){

			request.setAttribute("PwdMsg_code","验证码不正确!");
			return "pages/frame/findPwd.jsp";
		}

		//验证成功后销毁session中验证码
		request.getSession().removeAttribute("rCode");

}

 

你可能感兴趣的:(java,html,jquery)