2021年10月22日

          財務(wù)制度題庫

               摘要: 1財務(wù)制度題庫 單選題 1.下列各會計要素,(   )不是反映財務(wù)狀況的會計要素。 A.資產(chǎn)          B.負(fù)債          C.收入    ...  閱讀全文

          posted @ 2021-10-22 23:09 youngturk| 編輯 收藏

          2016年8月9日

          webwork 實現(xiàn)數(shù)據(jù)生成text文件,并進(jìn)行壓縮,并進(jìn)行下載

          //實現(xiàn)壓縮文件功能,采用commons-io-2.0.1.jar ,commons-compress-1.5.jar插件
                  final OutputStream out = new FileOutputStream("D:/EDI/EDi.zip");  //實例文件輸出流
                  ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, out);  
                  //實例化存檔輸出流,工廠方法創(chuàng)建zip的存檔輸出流
          //        File f1 = new File(file.getPath());
                  os.putArchiveEntry(new ZipArchiveEntry(file.getName()));  //生成存檔文件名
                  IOUtils.copy(new FileInputStream(file), os);  //添加拷貝存檔文件
                  
                  os.closeArchiveEntry();  
                  os.close();  
                  
                  //*************************
                  try {
                      File input = new File("D:/EDI/EDi.zip");//獲得下載文件路徑
                      contentType="application/octet-stream";
                      docStream = new FileInputStream(input);//獲得輸入流名稱
                      contentDisposition =URLEncoder.encode(input.getName() ,"UTF-8");
                     } catch (FileNotFoundException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                     }  
                     return "download";
          WEBWORK的文件下載機(jī)制。使用起來還是比較簡單的。
          下面是用法說明:
          首先在一個ACTION中,如果判斷有權(quán)限進(jìn)行文件下載。
          則:
          1、讀出該下載文件,并生成一個流。 文件名應(yīng)當(dāng)從請求的request中讀出,或從用戶的表中取出。
          public String downLoadFile(String fileName){
             try {
              File input = new File("e:/engilish literature.doc");
              docStream = new FileInputStream(input);
              contentDisposition = "test.txt";
             } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
             }  
             return "download";
          }
          2、將輸出導(dǎo)向到一個特殊的RESULT中去。叫做Steam Result。
                   <action name="register" class="com.job2easy.web.user.RegisterAction">
                       <result name="success" type="dispatcher">
                           <param name="location">/home/register-result.jsp</param>
                       </result>
                       <result name="input">
                           <param name="location">/home/register.jsp</param>
                       </result>
                       <result name="download" type="stream">
                           <param name="contentType">application/x-msdownload</param>
                           <param name="inputName">docStream</param>
                           <param name="bufferSize">1024</param>              
                           <param name="contentDisposition">attachment;filename="${contentDisposition}"</param>
                       </result>

                       <interceptor-ref name="params"/>
                   </action>
          3、這中間有幾個參數(shù)需要配置:
               contentType設(shè)成 application/x-msdownload 就可以。這樣瀏覽器會保證彈出一個下載文件的對話框。
              inputName 這個比較重要,這個名字是輸入流的名稱, 以后要steam result的實現(xiàn)類中為根據(jù)OGNL的表達(dá)式去查找的。
              contentDisposition 這個是下載之后,保存在用戶端的文件名稱。${contentDisposition} 看一下代碼。如果寫成上述的方式,就有機(jī)會在ACTION中設(shè)置文件名。
          4、另外一個參數(shù):contentLength就是下載文件的大小,webwork的stream result似乎實現(xiàn)有問題,不能根據(jù)文件的大小動態(tài)進(jìn)行設(shè)置,只能寫死。
               這個參數(shù)的意義是告訴瀏覽下載的文件有多大,以便瀏覽器正確的顯示進(jìn)度條。如果這個功能很重要的話,可以重新寫一個RESULT來實現(xiàn)。
          0

          posted @ 2016-08-09 17:49 youngturk 閱讀(270) | 評論 (0)編輯 收藏

          2016年8月8日

          經(jīng)典

          http://blog.csdn.net/jackfrued/article/details/44921941

          posted @ 2016-08-08 15:07 youngturk 閱讀(186) | 評論 (0)編輯 收藏

          2016年8月4日

          sql行列互轉(zhuǎn)

          數(shù)據(jù)列出來如下:
           ID NAME    COUR SCORE
          --- ------- ---- -----
            1 name_1  語文    33
            1 name_1  數(shù)學(xué)    63
            1 name_1  英語    71
            1 name_1  歷史    68
            1 name_1  化學(xué)    94
            2 name_2  語文    85
            2 name_2  數(shù)學(xué)     4
            2 name_2  英語    98
            2 name_2  歷史     9
            2 name_2  化學(xué)    12
            3 name_3  語文    49
            3 name_3  數(shù)學(xué)    96
            3 name_3  英語    30
            3 name_3  歷史    60
            3 name_3  化學(xué)     2
          要實現(xiàn)的行轉(zhuǎn)列的效果如下(或者類似的結(jié)果):
           ID NAME    SCORES
          --- ------- --------------------
            1 name_1  33,63,71,94,68
            2 name_2  85,4,98,12,9
            3 name_3  49,2,60,96,30
          通過case表達(dá)式
          select id,name,sum(case when course='語文' then score end) "語文",
          sum(case when course='數(shù)學(xué)' then score end) "數(shù)學(xué)",
          sum(case when course='英語' then score end) "英語",
          sum(case when course='歷史' then score end) "歷史",
          sum(case when course='化學(xué)' then score end) "化學(xué)"
          from HANG2LIE
          group by id,name;

          union有去重功能:
          結(jié)構(gòu)如下:
           ID NAME       Chinese       Math    English    History  Chemistry
          --- ------- ---------- ---------- ---------- ---------- ----------
            2 name_2          85          4         98          9         12
            1 name_1          33         63         71         68         94
            3 name_3          49         96         30         60          2
          我們要實現(xiàn)如下的查詢效果:列轉(zhuǎn)行
           ID NAME     COUR SCORE
          --- -------- ---- -----
            2 name_2   語文    85
            1 name_1   語文    33
            3 name_3   語文    49
            2 name_2   數(shù)學(xué)     4
            1 name_1   數(shù)學(xué)    63
            3 name_3   數(shù)學(xué)    96
            2 name_2   英語    98
            1 name_1   英語    71
            3 name_3   英語    30
            2 name_2   歷史     9
            1 name_1   歷史    68
            3 name_3   歷史    60
            2 name_2   化學(xué)    12
            1 name_1   化學(xué)    94
            3 name_3   化學(xué)     2
          1、集合查詢
          實現(xiàn)的SQL語句:
          select id,name,'語文' course,chinese score from lie2hang
          union
          select id,name,'數(shù)學(xué)' course,math score from lie2hang
          union
          select id,name,'英語' course,english score from lie2hang
          union
          select id,name,'歷史' course,history score from lie2hang
          union
          select id,name,'化學(xué)' course,chemistry score from lie2hang;

          posted @ 2016-08-04 17:51 youngturk 閱讀(196) | 評論 (0)編輯 收藏

          oracle 分頁 偽列 只能小于 不能大于

          select * from (select A.*, rownum rn from T_CD_LOC A where rownum > 20) where rn <41 錯


          select * from (select t.* ,rownum rn from T_CD_LOC t where rownum<=40) where rn>=20 對
          firstIndex=0
          pageNumber
          pageSize=20
          select * from (select A.*,rownum rn from T_CD_LOC a where rownum < ((firstIndex+pageNumber+1)*pageSize) where rn >((firstIndex+pageNumber)*pageSize)

          posted @ 2016-08-04 08:53 youngturk 閱讀(215) | 評論 (0)編輯 收藏

          2016年7月13日

          js怎么刷新都不管用

          js被緩存了,加控制版本 <script src="../lib_js/paymentplan.js?v=1"></script> 

          posted @ 2016-07-13 15:36 youngturk 閱讀(201) | 評論 (0)編輯 收藏

          2016年7月10日

          Ehcache學(xué)習(xí) 轉(zhuǎn)2

               摘要: EhCache 分布式緩存/緩存集群開發(fā)環(huán)境:System:WindowsJavaEE Server:tomcat5.0.2.8、tomcat6JavaSDK: jdk6+IDE:eclipse、MyEclipse 6.6 開發(fā)依賴庫:JDK6、 JavaEE5、ehcache-core-2.5.2.jarEmail:hoojo_@126.comBlog:http://blog.csdn...  閱讀全文

          posted @ 2016-07-10 17:14 youngturk 閱讀(210) | 評論 (0)編輯 收藏

          2016年7月9日

          java 虛擬機(jī)監(jiān)控

          3、JConsole監(jiān)控

               JMX(Java Management Extensions)是一個為應(yīng)用程序植入管理功能的框架。JMX是一套標(biāo)準(zhǔn)的代理和服務(wù),實際上,用戶可以在任何Java應(yīng)用程序中使用這些代理和服務(wù)實現(xiàn)管理。可以利用JDK的JConsole來訪問Tomcat JMX接口實施監(jiān)控,具體步驟如下:

          1)首先,打開Tomcat5的bin目錄中的catalina.bat文件,添加:

          JAVA_OPTS="-Xms512m -Xmx512m -Xmn256m  -XX:PermSize=64m -XX:MaxPermSize=64m  -Djava.rmi.server.hostname=192.168.222.132 -Dcom.sun.management.jmxremote.port=1090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

          -Dcom.sun.management.jmxremote:代表開啟JMX的管理功能

          2)重啟tomcat,并查看監(jiān)控端口(上面配置的1090)是否已啟動

          3)打開jdk的bin目錄(如C:\Program Files\Java\jdk1.7.0_17\bin)下的JConsole,并輸入iP和監(jiān)控端口進(jìn)行連接

               

           

          監(jiān)控結(jié)果:

               

          posted @ 2016-07-09 16:06 youngturk 閱讀(182) | 評論 (0)編輯 收藏

          hibernate 刪除關(guān)聯(lián)表

          http://www.itzhai.com/hibernate-one-to-many-association-mapping-configuration-and-the-cascade-delete-problem.html首先舉一個簡單的一對多雙向關(guān)聯(lián)的配置:

          一的一端:QuestionType類

          package com.exam.entity;
          import java.util.Set;
          public class QuestionType {
              private String typeName;
              private char typeUniqueness;
              private Set quesion;
              public String getTypeName() {
                  return typeName;
              }
              public void setTypeName(String typeName) {
                  this.typeName = typeName;
              }
              public char getTypeUniqueness() {
                  return typeUniqueness;
              }
              public void setTypeUniqueness(char typeUniqueness) {
                  this.typeUniqueness = typeUniqueness;
              }
              public Set getQuesion() {
                  return quesion;
              }
              public void setQuesion(Set quesion) {
                  this.quesion = quesion;
              }
          }

          配置文件:

          <hibernate-mapping package="com.exam.entity">
              <class name="QuestionType" table="exam_question_type">
                  <id name="typeName" column="type_name"></id>
                  <property name="typeUniqueness"  column="type_uniqueness"/>
                  <set name="quesion" inverse="true" cascade="delete">
                      <key column="question_type_name"/>
                      <one-to-many class="Question"/>
                  </set>
              </class>
          </hibernate-mapping>

          多的一端:Question類

          package com.exam.entity;
          import java.util.Date;
          public class Question {
              private int questionNo;
              private QuestionType questionType;
              private String questionsTitle;
              public int getQuestionNo() {
                  return questionNo;
              }
              public void setQuestionNo(int questionNo) {
                  this.questionNo = questionNo;
              }
              public QuestionType getQuestionType() {
                  return questionType;
              }
              public void setQuestionType(QuestionType questionType) {
                  this.questionType = questionType;
              }
              public String getQuestionsTitle() {
                  return questionsTitle;
              }
              public void setQuestionsTitle(String questionsTitle) {
                  this.questionsTitle = questionsTitle;
              }
          }

          配置文件:

          <hibernate-mapping package="com.exam.entity">
              <class name="Question" table="exam_question">
                  <id name="questionNo" column="question_no" >
                      <generator class="increment" />
                  </id>
                  <many-to-one name="questionType" column="question_type_name"/>
                  <property name="questionsTitle" column="questions_title" length="200" />    
              </class>
          </hibernate-mapping>

          首先說明一下一些常用的屬性:

          <many-to-one>元素包含以下屬性:

          name:設(shè)定映射的持久化類的屬性名
          column:設(shè)定和持久化類的屬性對應(yīng)的表的外鍵
          class:設(shè)定持久化類的屬性的類型
          cascade:設(shè)定是否級聯(lián)
          lazy:設(shè)定是否延遲加載

          <set>元素包含以下屬性:

          name:設(shè)定映射的持久化類的屬性名
          cascade:設(shè)置是否級聯(lián)
          inverse:設(shè)定反向控制,如果為true則一的一端不維護(hù)外鍵
          <key>:設(shè)定與所關(guān)聯(lián)的持久化類對應(yīng)的表的外鍵。
          one-to-many:設(shè)定所關(guān)聯(lián)的持久化類

          如果要對一對多關(guān)聯(lián)映射進(jìn)行級聯(lián)刪除,可以按照上面的舉例進(jìn)行配置:

          首先看到一的一端:

          <set name="quesion" inverse="true" cascade="delete">
              <key column="question_type_name"/>
              <one-to-many class="Question"/>
          </set>

          這里設(shè)置inverse表示一的一端不維護(hù)外鍵,設(shè)置cascade=”delete”表示刪除一的一端時對關(guān)聯(lián)到得多的所有的對象也一起刪除

          再看到多的一端:

          <many-to-one name="questionType" column="question_type_name"/>

          這里的column表示外鍵的名,需要和一的一端設(shè)置的key標(biāo)簽里的column保持一致,表示維護(hù)同一個鍵值。

          可以按照如下的代碼執(zhí)行刪除操作:

          session.beginTransaction();

          QuestionType questionType = (QuestionType) session.load(QuestionType.class, "判斷題");            
          session.delete(questionType);        
          session.getTransaction().commit();

          這里使用load查上來的對象是持久狀態(tài)的(Persistent),只有是Persistent狀態(tài)的對象才可以使用session.delete()操作進(jìn)行級聯(lián)刪除,由new創(chuàng)建的對象屬于Transient狀態(tài),不能進(jìn)行session.delete()操作。

          posted @ 2016-07-09 14:21 youngturk 閱讀(304) | 評論 (0)編輯 收藏

          hibernate 刪除關(guān)聯(lián)表

          需要先刪子表,再刪除主表,否則報錯 好文章 http://www.itzhai.com/hibernate-one-to-many-association-mapping-configuration-and-the-cascade-delete-problem.html

          posted @ 2016-07-09 14:18 youngturk 閱讀(204) | 評論 (0)編輯 收藏

          僅列出標(biāo)題  下一頁
          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          導(dǎo)航

          統(tǒng)計

          公告

          this year :
          1 jQuery
          2 freemarker
          3 框架結(jié)構(gòu)
          4 口語英語

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          EJB學(xué)習(xí)

          Flex學(xué)習(xí)

          learn English

          oracle

          spring MVC web service

          SQL

          Struts

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 雅江县| 临西县| 宜昌市| 上林县| 迁西县| 军事| 苍梧县| 哈尔滨市| 桑日县| 淮阳县| 区。| 长泰县| 九龙坡区| 荃湾区| 射阳县| 莒南县| 咸丰县| 屯昌县| 峨眉山市| 融水| 皮山县| 浪卡子县| 蓬安县| 舒城县| 阿荣旗| 彭水| 台前县| 吉安市| 大兴区| 六盘水市| 高淳县| 沾益县| 安国市| 罗甸县| 九台市| 化州市| 台北县| 香河县| 扶沟县| 理塘县| 巧家县|