jsp頁面ajax返回list(裡面放有物件)進行迴圈並插入table
阿新 • • 發佈:2019-01-10
@ResponseBody
@RequestMapping(value = "searchSource")
public void searchSource(HttpServletRequest request,HttpServletResponse response, Model model){
MemberInfo member = isLogin(request, response);
Map<String, Object> result = new HashMap<String,Object>();
Long typeSource = RequestUtil.getLong(request, "typeSource");
String sourceName = RequestUtil.getString(request, "sourceName");
System.out.println("sourceName:"+sourceName);
System.out.println("typeSource:"+typeSource);
result.put("result", "success");
result.put("message", "獲取成功!");
if(member!=null && member.getId()>0){
if(typeSource==1){
MaterialVideo materialVideo=new MaterialVideo();
materialVideo.setMemberId(member.getId());
materialVideo.setName(sourceName);
List<MaterialVideo> listVideo=materialVideoService.findByMemberId(materialVideo);
System.out.println("listVideo:"+listVideo.size());
if(listVideo.size()>0){
result.put("result", "success");
result.put("listSource", listVideo);
result.put("message", "獲取成功!");
}else{
result.put("result", "false");
result.put("message", "沒有該素材");
}
}
if(typeSource==2){
MaterialAudio materialAudio=new MaterialAudio();
materialAudio.setMemberId(member.getId());
materialAudio.setName(sourceName);
List<MaterialAudio> listAudio=materialAudioService.findByMemberId(materialAudio);
System.out.println("listAudio:"+listAudio.size());
if(listAudio.size()>0){
result.put("result", "success");
result.put("listSource", listAudio);
result.put("message", "獲取成功!");
}else{
result.put("result", "false");
result.put("message", "沒有該素材");
}
}
}
writeJson(request, response, result);
}
@RequestMapping(value = "searchSource")
public void searchSource(HttpServletRequest request,HttpServletResponse response, Model model){
MemberInfo member = isLogin(request, response);
Map<String, Object> result = new HashMap<String,Object>();
Long typeSource = RequestUtil.getLong(request, "typeSource");
String sourceName = RequestUtil.getString(request, "sourceName");
System.out.println("sourceName:"+sourceName);
System.out.println("typeSource:"+typeSource);
result.put("result", "success");
result.put("message", "獲取成功!");
if(member!=null && member.getId()>0){
if(typeSource==1){
MaterialVideo materialVideo=new MaterialVideo();
materialVideo.setMemberId(member.getId());
materialVideo.setName(sourceName);
List<MaterialVideo> listVideo=materialVideoService.findByMemberId(materialVideo);
System.out.println("listVideo:"+listVideo.size());
if(listVideo.size()>0){
result.put("result", "success");
result.put("listSource", listVideo);
result.put("message", "獲取成功!");
}else{
result.put("result", "false");
result.put("message", "沒有該素材");
}
}
if(typeSource==2){
MaterialAudio materialAudio=new MaterialAudio();
materialAudio.setMemberId(member.getId());
materialAudio.setName(sourceName);
List<MaterialAudio> listAudio=materialAudioService.findByMemberId(materialAudio);
System.out.println("listAudio:"+listAudio.size());
if(listAudio.size()>0){
result.put("result", "success");
result.put("listSource", listAudio);
result.put("message", "獲取成功!");
}else{
result.put("result", "false");
result.put("message", "沒有該素材");
}
}
}
writeJson(request, response, result);
}