我用的是springmvc我想把Controller中的List传到前台去怎么传? 前台怎么获取到list的值?
@RequestMapping(value="/address")publicStringfindaddress(){ReceivedGoodsAddressreceiv...
@RequestMapping(value="/address")
public String findaddress(){
ReceivedGoodsAddress receivedgoodsaddress=new ReceivedGoodsAddress();
List<ReceivedGoodsAddress> list = addressService.findReceivedGoodsAddress(receivedgoodsaddress);
return “jsp路径”
} 展开
public String findaddress(){
ReceivedGoodsAddress receivedgoodsaddress=new ReceivedGoodsAddress();
List<ReceivedGoodsAddress> list = addressService.findReceivedGoodsAddress(receivedgoodsaddress);
return “jsp路径”
} 展开
展开全部
用@ResponseBody
@RequestMapping(value = "/address", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> addressPOST() {
Map<String, Object> map = new HashMap<>();
ReceivedGoodsAddress receivedgoodsaddress=new ReceivedGoodsAddress();
List<ReceivedGoodsAddress> list = addressService.findReceivedGoodsAddress(receivedgoodsaddress);
map.clear();
map.put("list", list);
return map;
}
//前台用jquery+ajax
$.ajax({
type:'POST',
url:'${contextPath}/address',
dataType:'json',
success:function(data){
$.each(data.list,function(i,item){
alert(i);
alert(item.id);
alert(item.name);
});
}
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询