Todayfreeman

          BlogJava 聯系 聚合 管理
            4 Posts :: 2 Stories :: 3 Comments :: 0 Trackbacks

          2006年3月30日 #

          這幾天事情太多,弄的有些疲憊,不過除了工作原因跟女友暫時分居兩地外,其余的也都是好事居多.疲憊之余也多了幾分安慰。
          已經一年多沒有回家了。反倒不覺得如何,倒是中間回過兩次家的女友,喜歡拉我一起盤算51回家的事宜,說到回家,滿腦子想的最多的莫過于"吃",從羊肉包子到涼皮.再從搟面皮到涮羊肉,兩個人經常說的口水橫飛.欲罷不能.狠不得把濮陽能吃的都吃完,省的給自己留下殘念.
          如果時間允許,51真要回去一趟了.有些想念家人了。

          posted @ 2006-03-30 16:00 當理想插上程序的翅膀 閱讀(229) | 評論 (0)編輯 收藏

          2006年3月16日 #

          Hibernate 查詢時 服務器報java.lang.NoClassDefFoundError: antlr/ANTLRException
          原因是lib里少了antlr-2.7.5H3.jar 這個文件。。郁悶了一個下午。
          加上后一切成功。。Hibernate好東西。
          posted @ 2006-03-16 20:18 當理想插上程序的翅膀 閱讀(2796) | 評論 (2)編輯 收藏

          2006年3月13日 #

          這個問題讓我郁悶了兩三天時間,最后才發現問題是在JSP端  <html:form action="/uploadsAction"  enctype="multipart/form-data"  >
          標簽如果少了"  enctype="multipart/form-data"  服務器就會報錯,
          下面把代碼貼出來.

          JSP端
           <html:errors />
                    <html:form action="/uploadsAction"  enctype="multipart/form-data"  >
                      <html:file property="theFile" /> 
                       <html:radio property="upType" value="a" />CSVFileReader
                       <html:radio property="upType" value="b" />FileUp      
                      <html:submit value="OK"  />
                    </html:form>
          FormBean中將屬性定義為FormFile,geter seter 方法依舊.
          Action 中的代碼如下:實現將圖片上傳至UPLOAD文件夾內 如果文件大于20K或是寬&高超過規定范圍的,會重新勾畫.實現對上傳圖片的控制.
          當然這只是測試Action沒有跳轉頁面..

          package upload;

          import org.apache.struts.action.ActionMapping;
          import org.apache.struts.action.ActionForm;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.Action;
          import org.apache.struts.upload.*;
          import java.io.IOException;
          import java.awt.Image;
          import java.awt.image.BufferedImage;
          import com.sun.image.codec.jpeg.JPEGImageEncoder;
          import com.sun.image.codec.jpeg.JPEGCodec;

          import java.io.File;
          import java.io.BufferedInputStream;
          import java.io.BufferedOutputStream;
          import java.io.FileOutputStream;

          public class UploadAction extends Action {
              public ActionForward execute(ActionMapping actionMapping,
                                           ActionForm actionForm,
                                           HttpServletRequest servletRequest,
                                           HttpServletResponse servletResponse)throws Exception {
                  System.out.println("asdasdasdasdasdasd");
                  UploadForm uploadForm = (UploadForm) actionForm;
                  FormFile pic =  uploadForm.getPic();
                  String picname = pic.getFileName();
                  String uploadFileName = servletRequest.getSession()
                                          .getServletContext()
                                          .getRealPath("upload")+"\\"+picname;
                  File upliadFile = new File(uploadFileName);
                  BufferedInputStream bis = null;
                  Image image = null;
                  BufferedOutputStream bos = null;
                  try{
                  if(pic.getFileSize()<2*1024*1024){
                  bis = new BufferedInputStream(pic.getInputStream());
                  image = javax.imageio.ImageIO.read(bis);
                  int width = image.getWidth(null);
                  int height = image.getHeight(null);
                  int w = 160;
                  int h = 120;
                  if(width>w||height>h){
                  BufferedImage bi = new BufferedImage(w,h,
                                                       BufferedImage.TYPE_INT_RGB);
                  bi.getGraphics().drawImage(image,0,0,w,h,null);
                  bos = new BufferedOutputStream(new FileOutputStream(
                 upliadFile));
                  JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
               encoder.encode(bi);
                  System.out.println(width * height);
                  }else{
                  bos = new BufferedOutputStream(new FileOutputStream(upliadFile));
                  byte[] date = new byte[5*1024];
                  int len = bis.read(date);
                  while (len!=-1){
                      bos.write(date);
                      len = bis.read(date);
                  }
                  }
                  }
                       return actionMapping.findForward("ok");
                  }catch(Exception e){
                  e.printStackTrace();
              } finally {
                  try {
                      if (bis != null)
                          bis.close();
                  } catch (IOException e1) {

                      e1.printStackTrace();
                  }
                  try {
                      if (bos != null)
                          bos.close();
                  } catch (IOException e2) {

                      e2.printStackTrace();
                  }
              }

                  return actionMapping.findForward("ok");
              }
          }

          posted @ 2006-03-13 19:38 當理想插上程序的翅膀 閱讀(616) | 評論 (0)編輯 收藏

          已經很久沒有寫東西了,究其原因:
          一則是因為缺少了寫東西的必要動機,
          二則是隨著年齡增加,咬文嚼字,賣弄文筆,吹噓裝B的功力已大不如以前,通常硬要坐在電腦前寫東西時,腦海中總會下意識的浮現出中學時代每個星期四的下午..
          三則自從拜倒在JAVA石榴裙下后,對中文文字的敏感度已經退化到近似文盲的階段,所以只能在嘈雜的互聯網上辟出一塊自留地,以便自己發泄,好歹有"木子美""流氓燕"之流墊低,自然也放松許多.

          作為Blog的"開篇"自然要給它定一個基調,免的淪為靠公布自己的隱私博人一看的藏污納垢之地,
          思來想去將JAVA開發途中的遇到的問題以及解決方案和對新技術的理解,作為基調再何時不過,其中穿插進日常生活的影子也只是給枯燥的編程生活一些調劑,何樂而不為?!
          let's go~~~~

          posted @ 2006-03-13 19:14 當理想插上程序的翅膀 閱讀(271) | 評論 (1)編輯 收藏

          僅列出標題  
          主站蜘蛛池模板: 金秀| 游戏| 喀喇| 逊克县| 平定县| 清镇市| 涡阳县| 元谋县| 和平区| 三门峡市| 包头市| 兴国县| 会泽县| 扎赉特旗| 永修县| 宁津县| 庐江县| 蕉岭县| 上饶县| 广水市| 青神县| 巴东县| 瓦房店市| 淮安市| 阿克苏市| 正定县| 防城港市| 东山县| 临夏市| 德州市| 南江县| 秦皇岛市| 青州市| 本溪| 丰县| 平阴县| 阳新县| 称多县| 尖扎县| 彰化县| 石林|