• 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; 280px;overflow-y: hidden; word-wrap: break-word;' onpropertychange='this.style.height = this.scrollHeight + 'px';' oninput='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>
    
  • 相关阅读:
    shuffle过程分析
    自定义分组
    自定义排序及Hadoop序列化
    MapReduce常见算法
    Partitioner
    Combiner
    自定义Counter使用
    WordCount_命令行运行时指定参数
    老的API实现WordCount
    Hadoop自定义类型处理手机上网日志
  • 原文地址:https://www.cnblogs.com/wujixing/p/5800560.html
Copyright © 2020-2023  润新知