1. 程式人生 > >研究生期間第一篇博文

研究生期間第一篇博文

好久沒有更新部落格了,這兩年好像一直在忙,也不知道忙的是什麼。自從2015年9月進入大三,就離開了ACM實驗室,開始著手準備考研。沒有離開的時候,想著大三不去寫程式碼,不去研究枯燥的演算法,總覺得自己的生活會過得很輕鬆,可是當我真正收拾自己的東西離開座位的瞬間,對整個實驗室充滿了不捨。大三的時候每天除了上課就是去圖書館,大三的時候專業課比較多,計算機網路,計算機組成原理,作業系統,這三門專業都是在大三的時候開始學的。大三的時候就想好好學習,能在大三學年結束的時候拿到獎學金,每天晚上都會和小夥伴們一起去啟航上考研課。每次聽商志的英語都會記很多筆記(雖然這些筆記很少再會看第二遍),聽他的課總會讓我們很振奮,相信很多考研的小夥伴都會有這種感覺吧。大四的時候,我們學校就沒有課,全心全意的投入自己考研的複習,當時定的目標是鄭州大學,考研的這一年經歷了很多事,那時候每週給家人打電話的時候,總會給家人說考研好難,好多不會。雖然我知道說這些父母也不能給我什麼幫助,但是我還是覺得說出來會好一點。現在回首看自己本科的生活,考研這次經歷鍛鍊了我很多,也讓我成長了很多。2017年6月我正式拿到鄭州大學的錄取通知書,就這樣,繼續我的上學生涯,由於本科沒有學過java,現在在做專案的時候,要學習的東西很多。

從2017年8月份開始寫程式碼到現在接觸更多的就是前臺和後天的互動,簡單總結一下專案中使用的兩種互動方法:

前臺選擇開始日期
 <div class="layui-input-inline">
       <input type="text" class="layui-input" id="test1" name="date1" value="<s:property value="#date1"/>">
 </div>  
後臺獲取前臺的值	                                           
HttpServletRequest request = ServletActionContext.getRequest();                         
String date1 = request.getParameter("date1");// 開始時間
把後臺的值傳給前臺                                                                                                      
ActionContext.getContext().put("date1", date1);
前臺程式碼:非同步請求傳值(首尾圖片ID:swyid)
$.ajax({                           		    
               type: "POST",  
               url: "${pageContext.request.contextPath}/swyPicture_swypicid.action", //傳送請求  
               data: {swypid:id},  
               dataType:"json",                    
                success: function(result) {                     
                       }                     
        })   
後臺獲取方法:	
	// 獲取當前行的id
	public String swypicid() throws Exception {
		if(swypid!=null && !"".equals(swypid)){		
			ServletActionContext.getRequest().getSession().setAttribute("swypid",swypid);
		}	
			
        HttpServletResponse response=ServletActionContext.getResponse();
        response.setCharacterEncoding("utf-8");
		PrintWriter printWriter=response.getWriter();
		printWriter.write(JSON.toJSONString("success"));
		printWriter.close();			
		return null;	
	}
非同步請求後臺向前臺傳值//attPa                                                                             
	public String showpic() throws Exception {
		
		Long swyPid = new Long(0);
if(ServletActionContext.getRequest().getSession().getAttribute("swypid")!=null && !"".equals(ServletActionContext.getRequest().
getSession().getAttribute("swypid")))
		{
			
			swyPid=Long.parseLong(ServletActionContext.getRequest().getSession().getAttribute("swypid").toString());
		}
		
		// 獲取顯示圖片的附件路徑
		SwyPicture swyp = swyPictureService.getById(swyPid);		
		String attPa = swyp.getAttPath();
		if(attPa!=null && !"".equals(attPa)){		
	        ServletActionContext.getRequest().getSession().setAttribute("attPa",attPa);//向後臺傳值
		}	
			
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");	
		PrintWriter printWriter = response.getWriter();
		printWriter.write(attPa);  //傳給前臺
		printWriter.close();
		return null;
     }                     
前臺獲取方法:
 function show() {        var url = "${pageContext.request.contextPath}/swyPicture_showpic.action";    	
 		          $.post(url,function(attPa){      //獲取attPa                                                                     		
 		          var imgpath=attPa;                                                          						
                          var tid=$("tr[bgcolor='#eceeef']");                                       		
			 	var id=tid.attr("id");											              
    				var imgstr = $(['<img src="'
	                      ,'/file/' + imgpath
	                      ,'" id="img' 
	                      ,'" style="margin-bottom: 5px;width: 60%"/>'].join(''));                 
	            $("#testDataImg").empty();             
	            $("#testDataImg").prepend(imgstr);     		 
             });		    		     
                                                     
	};