springmvc传递json数据到前台显示

需要两个包 jackson-core-asl, jackson-mapper-asl

 

controller

@RequestMapping(value="/findEduList",produces="application/json;charset=UTF-8")
@ResponseBody
public List<Education> findEduList(String keyword, HttpServletRequest request,HttpServletResponse response){
	List<Education> eduList = eduService.findEduList(keyword);		
	return eduList; 
}

 

jsp文件

<div id="MainArea">
            <form action="">
            <table id = "tableEdu" cellspacing="0" cellpadding="0" class="TableStyle">
                
            </table>
               <div id="TableTail">
                    <div id="TableTail_inside">
                        <a href="/portal/edu/addEdu"><img src="<%=basePath %>style/images/createNew.png" /></a>
               </div>
               </div>
           </form>
    </div>  
<script type="text/javascript">
		   function search(delFlag){		   
			   var keyword =document.getElementById("selectitem").value;			   
			   $.getJSON("/portal/edu/findEduList?keyword="+keyword+"&rn="+Math.random(),function(dataSelect){		
					   var str="<thead>";
					   str+="<tr align='CENTER' valign='MIDDLE' id='TableTitle'>";
		        	   str+=" <td width='150px' rowspan='2'>Training Title</td>";
		        	   str+="<td width='80px' rowspan='2'>Objective</td>";
		        	   str+="<td width='300px' rowspan='2'>Contents</td>";
		        	   str+=" <td width='100px' rowspan='2'>Schedule</td>";
		        	   str+=" <td width='100px' rowspan='2'>Duration</td>";
		        	   str+="<td width='230px' colspan='2'>Trainer</td>";
		        	   str+="<td width='100px' rowspan='2'>Trainee</td>";
		        	   str+=" <td width='200px' rowspan='2'>Remarks</td>";
		        	   if(delFlag==true)
		        	   		str+="<td width='10px' rowspan='2'> <img border='0' width='15' height='15' src='../../style/images/del.png'/></td>";
		        	   else
					  	   	str+="<td></td>";
		        	   str+="</tr>";
		        	   str+="<tr align='CENTER' valign='MIDDLE' id='TableTitle'>";
		        	   str+="<td width='80px'>Name</td>";
		        	   str+="<td width='150px'>Department</td>";
		        	   str+="</tr></thead>";
		        	   
					 $.each(dataSelect,function(i){					 
						//for(var i = 0;i<data.length;i++){
						   var eduid = dataSelect[i].id;					   
						   var edutitle = dataSelect[i].edutitle;
						   var objective = dataSelect[i].objective;
						   var contents = dataSelect[i].contents;
						   var schedule = dataSelect[i].schedule;
						   var duration = dataSelect[i].duration;
						   var trainerName = dataSelect[i].trainerName;
						   var department = dataSelect[i].department;
						   var trainee = dataSelect[i].trainee;
						   var remarks =dataSelect[i].remarks;
						   str+="<tbody id='TableData' class='dataContainer' >";
						   str+="<tr class='TableDetail1 template'>	";
						   str+="<input type='hidden' name='id' value=eduid>";
						   str+="<td ><textarea name='textarea' class='t' id='edutitle'  value=edutitle onChange='updateEdu(this,"+eduid+")' style=' font-size:12px; color:#004779; border:0; width:280px;overflow-y: hidden; word-wrap: break-word;' onpropertychange='this.style.height = this.scrollHeight + 'px';' οninput='this.style.height = this.scrollHeight + 'px';'> "+edutitle+"</textarea></td>";
					  	   str+="<td><input type='text'  class='t' id='objective'   style='font-size:12px; color:#004779;'  onChange='updateEdu(this,"+eduid+")'  value="+objective+"> </td>";	
					  	   str+="<td><input type='text'  class='t' id='contents'   style='font-size:12px; color:#004779;'  onChange='updateEdu(this,"+eduid+")' value="+contents+"> </td>";
					  	   str+="<td><input type='text'  class='t' id='schedule'   style='font-size:12px; color:#004779;'  onChange='updateEdu(this,"+eduid+")' value="+schedule+"> </td>";
					  	   str+="<td><input type='text'  class='t' id='duration'   style='font-size:12px; color:#004779;'  onChange='updateEdu(this,"+eduid+")' value="+duration+"> </td>";
					  	   str+="<td><input type='text'  class='t' id='trainerName'  style='font-size:12px; color:#004779;'  onChange='updateEdu(this,"+eduid+")'  value="+trainerName+"> </td>";
					  	   str+="<td><input type='text'  class='t' id='department'   style='font-size:12px; color:#004779;'  onChange='updateEdu(this,"+eduid+")' value="+department+"> </td>";				  	
					  	   str+="<td><input type='text'  class='t' id='trainee'  style='font-size:12px; color:#004779;'  onChange='updateEdu(this,"+eduid+")'  value="+trainee+"> </td>";
					  	   str+="<td><input type='text'  class='t' id='remarks'   style='font-size:12px; color:#004779;'  onChange='updateEdu(this,"+eduid+")' value="+remarks+"> </td>";
					  	 	if(delFlag==true)
					  	   	  str+="<td><img border='0' width='15' height='15' src='../../style/images/lajitong.jpg'  onClick='javascript:del("+eduid+")' /></td>"; 
					  	   else
					  	   	  str+="<td></td>";
					  	   str+="</tr></tbody>";
					   });
					   $("#tableEdu").empty();
					   $("#tableEdu").append(str);
		 		});
		   }	 
		</script>

 

转载于:https://www.cnblogs.com/wujixing/p/5800560.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值