使用vue 的get()方法向后台获取数据

这里需要导入vue.js的jar包

<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery/jquery-2.1.4.min.js"></script>
<script src="js/vue.js"></script>
</head>
<body>
<div id="box"> 
	<input type="button" @click="get()" value="确定">
</div>
</body>
<script src="https://cdn.bootcss.com/vue-resource/1.5.1/vue-resource.min.js"></script>
<script type="text/javascript">
window.onload = function(){
    var vm = new Vue({
        el:'#box',
        data:{
        	sites:[ ],
        },
        methods:{ 
	        get:function(){
	            //发送get请求
	            this.$http({           //调用接口
                    method:'GET',
                    url:"adminRoleAction.action?methodName=queryAdminRole" , 
                    params:{ }
                }).then(function(params){  //接口返回数据  
                	console.log(params );
                },function(error){
                })
	        } 
	    }   
    });
}
</script>
</html>

后台代码:

	public String queryAdminRole(HttpServletRequest request,HttpServletResponse response) throws Exception{
		//获取的数据
		List<AdminRole> allAdminRole = iard.getAllAdminRole(adminRole, pb); 
		//将数据放入map集合
		Map<String, Object> map=new HashMap<>();
		map.put("rows", allAdminRole);
		mapper.writeValue(response.getOutputStream(), map);
		return null;
	}
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值