Spring mvc + form表单的ajax提交

html

中奖结果: 用户名

js(需要加载jquery)

submit = function(){
	$.ajax({
		url: "/prize",
		type: 'POST',
		data: $('#validForm').serialize(),
		dataType:"text",
		contentType: "application/x-www-form-urlencoded", //必须这样写可以自救用bean
		processData: false, //禁止jquery对DAta数据的处理,默认会处理
		success: function(data) {
				alert("成功!");
			}
		})
	}

java部分


	@RequestMapping(value="prize",method = RequestMethod.POST)
	@ResponseBody
	public Map submit( @Valid Result bean,Integer prizeId,Integer userId,
			HttpServletRequest request){
		。。。。。
		return null;
	}

 

你可能感兴趣的:(JavaScript,jQuery,java)