关于href 跳转,传参数,对象

window.location.href ,CSDN不容许这样直接传名称。所有就用了“href 跳转,传参数,对象”这个标题。

1.跳转
window.location.href进行页面跳转

window.location.href = url

2.传参数:
对应在springmvc 的Controller层中(String year,Stringmonth)接收
@RequestMapping(“exportExcelByQuery”)
@ResponseBody
public void exportExcelByQuery(HttpServletRequest request, HttpServletResponse response, integer year ,integer month)

var year = $("#year").val();
var month = $("#month").val();
window.location.href = "xxx.do?year="+year+'&month='+month

3.传对象 (excel导出功能)
@RequestMapping(“exportExcelByQuery”)
@ResponseBody
public void exportExcelByQuery(HttpServletRequest request, HttpServletResponse response, PersonSalaryQuery query)
前段控制器中的 PersonSalaryQuery query对应window.location.href 中的query

/*导出excel工资表 请求.do*/
function exportExcelByQuery() {
	var year = $("#year").val();
	var month = $("#month").val();
	var gradeClass = $("#gradeClasses").val();
	var url = "/swj_salary/personSalary/exportExcelByQuery.do";
	if (year == 0) {
		year = null;
	}

	if (month == 0) {
		month = null;
	}

	if (gradeClass == 0) {
		gradeClass = null;
	}
	
	var param = {
		//"personCode" : userName,
		"personCode" : 'hutt',
		"year" : year,
		"month" : month,
		"gradeCode" : gradeClass
	};
	var params = JSON.stringify(param);
	alert(params)
	$('tbody').empty(); // 置空
	
	var query = "";
	for(var key in param){
		if(param[key]){
			query += "&"+key+"="+param[key];
		}
	}
	window.location.href ="/swj_salary/personSalary/exportExcelByQuery.do?query="+query;
	}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值