??xml version="1.0" encoding="utf-8" standalone="yes"?>四虎影院在线域名免费观看,国产一区二区三区日韩,成人免费自拍视频http://www.aygfsteel.com/beyondduke/category/4174.htmlzh-cnWed, 12 Mar 2008 13:00:14 GMTWed, 12 Mar 2008 13:00:14 GMT60初学flexhttp://www.aygfsteel.com/beyondduke/archive/2008/03/12/185689.htmlbeyonddukebeyonddukeWed, 12 Mar 2008 06:28:00 GMThttp://www.aygfsteel.com/beyondduke/archive/2008/03/12/185689.htmlhttp://www.aygfsteel.com/beyondduke/comments/185689.htmlhttp://www.aygfsteel.com/beyondduke/archive/2008/03/12/185689.html#Feedback1http://www.aygfsteel.com/beyondduke/comments/commentRss/185689.htmlhttp://www.aygfsteel.com/beyondduke/services/trackbacks/185689.html     上大学的时候,看到好多_ֽ炫丽的flashQ学习了一些flash的知识。那个时候不怎么会写脚本Q就用动ȝ概念一帧一帧的拼出一个flash。后来工作以后,l客户在U演CZ品,有接触了Captivate?006q末的时候,客户要求开发一个在U品展C^収ͼ我偶然搜Cadobe用flex开发的|上购物演示Q就体会到如果用flex来实现这个品展C^台将是很动h的事情,׃某种原因最l未能如ѝ最q在做一个通用视频培训q_时又用到了FLV播放器,也是用Flex开发的Q最l效果和土豆、优酷非常类伹{这些场景我对flash的展现效果情有独钟,况且有adobeq样的公司在q作flashQ如果可能的话应该在合适的场合来把flex集成到我们现在开发的应用中,比如图表功能、表单功能、打印功能等{。基于以上的l历和思\Q决定花功夫学习一下flexq是值得的?br />     首先Q到adobe官方|站下蝲flex builder 3Q当前最新版本)q安装。安装完毕后会看C些入门文章中提到的Flex SDK已经在builder中存在了Q所以初学仅下蝲个builder够了?br />     然后Q打开builder发现它就是基于eclipse开发的Q我惌个IDE对于大多数java开发着再熟悉不q了。首ơ进入时会有一个欢q界面和初学者向|我比较习惯看看这些东西,点击下蝲提供的入门工EFlex3GSEIII_a_WorkingWithData_JSPQƈ导入builder中。看看工E结构跟我们qx的JAVAEE工程有了一些不同。多了bin-debug和html-template文g夹,文gcd主要?.mxml?.as。在工程的左侧视囑֏?.mxmlq行Q类gq行java文gQ,会有一个编译过E,q后弹出一个htmlQhtml中运行的正式flash。当时比较好奇,一个mxml是如何经q编译生html和flash的,打开刚才提到的bin-debug发现两个文g生成Cq个文g夏V仔l读一下mxml的代码发现跟XHTML基本cMQ其中的一些function都是AS写的。至此我分析得到如下l论Qmxml+as-->swf,中间的{换是adobe集成在builder中的转换工具完成的。如此跟我们以往HTML+JS的编E习惯很cM了,q且XHTML与AS的结合更紧密一些。由于初学原理性的知识我就理解x了?br />    最后,我们兛_的是用flex都能实现哪些控gQƈ且控件的效果如何。我没有q不及待的去googleQ而是又深入到builder的安装目录下Q在D:\Flex Builder 3\sdks\3.0.0发现了好东西Q别的我不关心,先看samplesQ子目录下有一个explorerQ其中包含一个build.bat。看到这个bat我更加确定了我以上的l论。于是运行batQ开始编译其下的mxml文g逐一生成swf文g。花一D|间生成完毕,打开cM于index的swf文gQsdk中提供的样例控g都收眼底了?br />    后箋Q有源文Ӟ有开发工P你可以随意摆弄这些代码,熟悉语法Q熟悉开发环境,熟悉对象属性,拼拼凑凑完成自己的一个组合界面了?/p>

beyondduke 2008-03-12 14:28 发表评论
]]>
数据库常见的三种join方式Q收藏)http://www.aygfsteel.com/beyondduke/archive/2006/05/18/46745.htmlbeyonddukebeyonddukeThu, 18 May 2006 01:43:00 GMThttp://www.aygfsteel.com/beyondduke/archive/2006/05/18/46745.htmlhttp://www.aygfsteel.com/beyondduke/comments/46745.htmlhttp://www.aygfsteel.com/beyondduke/archive/2006/05/18/46745.html#Feedback1http://www.aygfsteel.com/beyondduke/comments/commentRss/46745.htmlhttp://www.aygfsteel.com/beyondduke/services/trackbacks/46745.html数据库常见的join方式有三U:inner join, left outter join, right outter join(q有一Ufull joinQ因不常用,本文不讨?。这三种q接方式都是两个以上的表通过on条g语句Q拼成一个大表。以下是它们的共同点Q?/p>

  1. 关于左右表的概念。左表指的是在SQL语句中排在left join左边的表Q右表指的是排在left join双的表?br />  2. 在拼成的大表中,左表排在左边Q右表排在右辏V?br />  3. on条g语句最好用=号对两表相应的主外键q行q接。当Ӟ也可以用其他操作W,?gt;, <, 来连接两表的M字段Q此时的关系非常复杂,q接后的记录C随之而变得不定。如果在一些特D的场合中需要用到这U方式,必须通过单的实例加以认Q否则,q接l果很可能不是我们所惌的!
  4. on条g语句不能省略?br />  5. 可以q锁使用joinQ每ơ用join都o另一表与当前的表或连接的l果相连接?/p>


在下文中Q用C两个表,"部门"表与"l织"表,其中Q?部门"表有一名ؓ"l织~号"的外键,指向"l织"表中的主?~号"?/p>

inner join

  格式Qselect * from 部门 inner join l织 on 部门.l织~号 = l织.~号

  目的Q将两表中符合on条g的所有记录都扑և来?/p>

  规律Q?/p>

    1. 拼出的大表记录不会增加?br />    2. 如果左边与右表的关系是一对多的关p,在选出的Q一记录中,假若双有多个记录与其对应,那么Q连接后的左表,主键不再唯一?/p>

  典型应用Q将存在多关pȝ引用表放在左表,存在一关系的被引用表放在右表,通过=号将d键进行连接,通过对右表设定过滤条Ӟ选出相应的且主键唯一的左表记录?/p>

  备注Qinner join 是默认的q接方式Q可~写为join?/p>

  转化为where子句Q?/p>

    select * from 部门, l织 where 部门.l织~号 = l织.~号

 

left outter join

  格式: select * from 部门 left join l织 on 部门.l织~号 = l织.~号

  格式: select * from l织 left join 部门 on l织.~号 = 部门.l织~号

  目的Q将左表的所有记录列出,双中只要符合on条g的,与左表记录相拼合Q不W合条g的,填以null倹{?/p>

  规律Q?/p>

    1. 选出所有符合条件的左表Q如果左边与双的关pL一对一的关p,则拼成的大表记录不会改变?br />       如果左边与右表的关系是多对一的关p,则拼成的大表记录也不会改变?br />       如果左边与右表的关系是一对多的关p,则拼成的大表记录会增加。对于每一h一对多关系的左表记录,如果左表1QN与右表对应,那么会多出N-1条记录。例如,如果左表W一条记?Q?对应于右表,多出2条记录。如果左表第二条记录1Q?对应于右表,则再多出1条记录。这Pd多出3条记录。其他类推?br />    2. 如果左边与右表的关系是一对多的关p,在选出的Q一记录中,假若双有多个记录与其对应,那么Q连接后的左表,主键不再唯一?br />    3. 如果左边与右表的关系是一对多的关p,对于左表M记录Q如果右表没有记录与其相对应Q则全部填以null倹{?/p>

  典型应用Q将存在多关pȝ引用表放在左表,存在一关系的被引用表放在右表,通过对右表设定过滤条Ӟ选出相应的且主键唯一的左表记录?/p>

  备注Qleft outter join可用left join代替。在有些数据库中Q如HSqlDb, 只能使用left join而不能用left outter join?/p>

  转化为where子句Q?/p>

    select * from 部门, l织 where 部门.l织~号 = l织.~号


right outter join

  格式: select * from 部门 right join l织 on 部门.l织~号 = l织.~号

  格式: select * from l织 right join 部门 on 部门.l织~号 = l织.~号

  目的Q将双的所有记录列出,左表中只要符合on条g的,与右表记录相拼合Q不W合条g的,填以null倹{?/p>

  规律Q?与left outter join相反)

  典型应用Q可转化成left outter join。例?/p>

    select * from l织 right join 部门 on 部门.l织~号 = l织.~号
    ?br />    select * from 部门 left join l织 on 部门.l织~号 = l织.~号
    的效果一?/p>

  备注Qright outter join可用right join代替。在有些数据库中Q如HSqlDb, 没有实现right join功能?/p>

  转化为where子句Q?/p>

    select * from 部门, l织 where 部门.l织~号 = l织.~号



beyondduke 2006-05-18 09:43 发表评论
]]>
递归程?/title><link>http://www.aygfsteel.com/beyondduke/archive/2006/03/29/37965.html</link><dc:creator>beyondduke</dc:creator><author>beyondduke</author><pubDate>Wed, 29 Mar 2006 01:31:00 GMT</pubDate><guid>http://www.aygfsteel.com/beyondduke/archive/2006/03/29/37965.html</guid><wfw:comment>http://www.aygfsteel.com/beyondduke/comments/37965.html</wfw:comment><comments>http://www.aygfsteel.com/beyondduke/archive/2006/03/29/37965.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/beyondduke/comments/commentRss/37965.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/beyondduke/services/trackbacks/37965.html</trackback:ping><description><![CDATA[递归<img src ="http://www.aygfsteel.com/beyondduke/aggbug/37965.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/beyondduke/" target="_blank">beyondduke</a> 2006-03-29 09:31 <a href="http://www.aygfsteel.com/beyondduke/archive/2006/03/29/37965.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>E序员的方向http://www.aygfsteel.com/beyondduke/archive/2006/03/25/37317.htmlbeyonddukebeyonddukeSat, 25 Mar 2006 03:21:00 GMThttp://www.aygfsteel.com/beyondduke/archive/2006/03/25/37317.htmlhttp://www.aygfsteel.com/beyondduke/comments/37317.htmlhttp://www.aygfsteel.com/beyondduke/archive/2006/03/25/37317.html#Feedback0http://www.aygfsteel.com/beyondduke/comments/commentRss/37317.htmlhttp://www.aygfsteel.com/beyondduke/services/trackbacks/37317.html

beyondduke 2006-03-25 11:21 发表评论
]]>
linux 下配|java环境Qjdk和tomcat)http://www.aygfsteel.com/beyondduke/archive/2006/02/14/30573.htmlbeyonddukebeyonddukeTue, 14 Feb 2006 04:34:00 GMThttp://www.aygfsteel.com/beyondduke/archive/2006/02/14/30573.htmlhttp://www.aygfsteel.com/beyondduke/comments/30573.htmlhttp://www.aygfsteel.com/beyondduke/archive/2006/02/14/30573.html#Feedback0http://www.aygfsteel.com/beyondduke/comments/commentRss/30573.htmlhttp://www.aygfsteel.com/beyondduke/services/trackbacks/30573.htmlJDK的配|:

    1,  下蝲j2sdk-linux-i386-rpm.bin
    2Q运行命令:chmod +x j2sdk-linux-i386-rpm.bin     Q修Ҏ可执行权限)
    3Q执?FONT style="BACKGROUND-COLOR: #d3d3d3" color=#0000ff>Q?/ j2sdk-1_3_1-linux-i386-rpm.bin        (执行后生成rpm安装包j2sdk-linux-i386.rpm)
    4Q?FONT style="BACKGROUND-COLOR: #d3d3d3" color=#0000ff>rpm -ivh j2sdk-1_3_1-linux-i386-rpm     (安装成功后,jdk被安装?usr/java/目录?
    5,   vi当前用户Q例root目录下)?bash_profile文gQ添加内容如下:

1export JAVA_HOME=/usr/java/j2sdk1.4.2_10
2export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.
jar
3export PATH=$PATH:$JAVA_HOME/bin

     6Qjava命oQ验证环境是否配|成功?BR>
TOMCAT的配|:
    
     1Q下载jakarta-tomcat-5.0.28.tar.gz
     2Q?tar zxvf jakarta-tomcat.tar.gz
     3Q?转换路径cd到tomcat/bin目录?FONT style="BACKGROUND-COLOR: #d3d3d3" color=#0000ff>Q?/startup.sh
(启动tomcat)
     4Q?在ie览器输?A href="http://servername:port">http://servername:port   Q验证tomcat是否启动成功Q?BR>      

   



beyondduke 2006-02-14 12:34 发表评论
]]>
JDBC实现oracle blob 出库入库http://www.aygfsteel.com/beyondduke/archive/2006/02/14/30542.htmlbeyonddukebeyonddukeTue, 14 Feb 2006 01:23:00 GMThttp://www.aygfsteel.com/beyondduke/archive/2006/02/14/30542.htmlhttp://www.aygfsteel.com/beyondduke/comments/30542.htmlhttp://www.aygfsteel.com/beyondduke/archive/2006/02/14/30542.html#Feedback0http://www.aygfsteel.com/beyondduke/comments/commentRss/30542.htmlhttp://www.aygfsteel.com/beyondduke/services/trackbacks/30542.html      id         varcharQ?0Q?BR>      image   blob
2Qblob入库
      拯Sunset.jpg囄在C盘根目录?nbsp;    
 1      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); 
 2      Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:beyondduke","duke","duke"); 
 3      conn.setAutoCommit(false); 
 4      BLOB blob = null
 5      PreparedStatement pstmt = conn.prepareStatement("insert into imageTable(id,image) values(?,empty_blob())"); 
 6      pstmt.setString(1,"10001"); 
 7      pstmt.executeUpdate(); 
 8      pstmt.close(); 
 9      pstmt = conn.prepareStatement("select content from imageTable where id= ? for update"); 
10      pstmt.setString(1,"10001"); 
11      ResultSet rs = pstmt.executeQuery(); 
12     if (rs.next()) blob = (BLOB) rs.getBlob(1); 
13      String fileName = "c://Sunset.jpg"
14      File f = new File(fileName); 
15      FileInputStream fin = new FileInputStream(f); 
16      System.out.println("file size = " + fin.available()); 
17      pstmt = conn.prepareStatement("update imageTable set image=? where id=?"); 
18      OutputStream out = blob.getBinaryOutputStream(); 
19       byte[] data = new byte[(int)fin.available()]; 
20      fin.read(data); 
21      out.write(data); 
22      out.close(); 
23      fin.close(); 
24
25      pstmt.setBlob(1,blob); 
26      pstmt.setString(2,"fankai"); 
27
28      pstmt.executeUpdate(); 
29      pstmt.close(); 
30
31      conn.commit(); 
32      conn.close(); 
览数据库的数据Q发现image中数据大小与图片大一_说明入库了!
 3Qblob出库
 1   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
 2   Connection conn = DriverManager.getConnection(            "jdbc:oracle:thin:@localhost:1521:beyondduke""duke","duke");     
          conn.setAutoCommit(
false);
 3    Statement stmt = conn.createStatement();
 4/* 查询BLOB对象 */
 5    ResultSet rs = stmt.executeQuery("SELECT content FROM javatest WHERE id='1001'");
 6while (rs.next()) {
 7/* 取出此BLOB对象 */    
 8    oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob("image");
 9 BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("d://Sunset.jpg"));            
           BufferedInputStream in 
= new BufferedInputStream(blob    .getBinaryStream());        
10    int c;
11while ((c = in.read()) != -1{ out.write(c);        
12   }

13   in.close();
14   out.close();
15   rs.close();
16   stmt.close();
17   conn.close();
18
查D盘根目录Q会发现Sunset.jpg文gQ跟C盘下是一LQ说明入库出库成功!

beyondduke 2006-02-14 09:23 发表评论
]]>
跨^台的JAVA调不跨^台的C--QJNI在Win32&&Linux下的使用Q?/title><link>http://www.aygfsteel.com/beyondduke/archive/2005/12/21/24983.html</link><dc:creator>beyondduke</dc:creator><author>beyondduke</author><pubDate>Wed, 21 Dec 2005 10:54:00 GMT</pubDate><guid>http://www.aygfsteel.com/beyondduke/archive/2005/12/21/24983.html</guid><wfw:comment>http://www.aygfsteel.com/beyondduke/comments/24983.html</wfw:comment><comments>http://www.aygfsteel.com/beyondduke/archive/2005/12/21/24983.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/beyondduke/comments/commentRss/24983.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/beyondduke/services/trackbacks/24983.html</trackback:ping><description><![CDATA[<FONT size=2>   ׃javaE序需要调用C或C++的代码,不得不用JNI。C的代码在Win32和Linux下都有相同功能的不同实现Q就像JDK分几U^台版本(win32QlinuxQsolaris{)?BR>   <STRONG>首先Q看一看首先,看一看win32下调用dll文g?BR></STRONG>    1Q?新徏HelloWorld.java<BR></FONT> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><FONT size=2><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"> HelloWorld<BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_24_281_Open_Image onclick="this.style.display='none'; Codehighlighter1_24_281_Open_Text.style.display='none'; Codehighlighter1_24_281_Closed_Image.style.display='inline'; Codehighlighter1_24_281_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_24_281_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_24_281_Closed_Text.style.display='none'; Codehighlighter1_24_281_Open_Image.style.display='inline'; Codehighlighter1_24_281_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_24_281_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN></FONT><SPAN id=Codehighlighter1_24_281_Open_Text><FONT size=2><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff">static</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_37_220_Open_Image onclick="this.style.display='none'; Codehighlighter1_37_220_Open_Text.style.display='none'; Codehighlighter1_37_220_Closed_Image.style.display='inline'; Codehighlighter1_37_220_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_37_220_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_37_220_Closed_Text.style.display='none'; Codehighlighter1_37_220_Open_Image.style.display='inline'; Codehighlighter1_37_220_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>  </SPAN><SPAN id=Codehighlighter1_37_220_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN></FONT><SPAN id=Codehighlighter1_37_220_Open_Text><FONT size=2><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">try</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_51_120_Open_Image onclick="this.style.display='none'; Codehighlighter1_51_120_Open_Text.style.display='none'; Codehighlighter1_51_120_Closed_Image.style.display='inline'; Codehighlighter1_51_120_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_51_120_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_51_120_Closed_Text.style.display='none'; Codehighlighter1_51_120_Open_Image.style.display='inline'; Codehighlighter1_51_120_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN id=Codehighlighter1_51_120_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN></FONT><SPAN id=Codehighlighter1_51_120_Open_Text><FONT size=2><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">此处即ؓ本地Ҏ所在链接库?/SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">      System.loadLibrary(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">HelloWorld</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_150_216_Open_Image onclick="this.style.display='none'; Codehighlighter1_150_216_Open_Text.style.display='none'; Codehighlighter1_150_216_Closed_Image.style.display='inline'; Codehighlighter1_150_216_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_150_216_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_150_216_Closed_Text.style.display='none'; Codehighlighter1_150_216_Open_Image.style.display='inline'; Codehighlighter1_150_216_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    }</SPAN></FONT></SPAN><FONT size=2><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(UnsatisfiedLinkError e)</SPAN><SPAN id=Codehighlighter1_150_216_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN></FONT><SPAN id=Codehighlighter1_150_216_Open_Text><FONT size=2><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      System.err.println( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">不能加蝲dll文g:\n </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000">e.toString() );<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></FONT></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>  }</SPAN></FONT></SPAN><FONT size=2><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">end static</SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">native</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"> SayHello(String strName);<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></FONT></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></FONT></DIV><FONT size=2>  2,  ~译java文g生成HelloWorld.class文g<BR>  3Q在命o行下Qjavah -jni HelloWorld 生成 HelloWorld.h 文g<BR>   </FONT> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><FONT size=2><SPAN style="COLOR: #008080"> 1</SPAN><IMG id=Codehighlighter1_0_52_Open_Image onclick="this.style.display='none'; Codehighlighter1_0_52_Open_Text.style.display='none'; Codehighlighter1_0_52_Closed_Image.style.display='inline'; Codehighlighter1_0_52_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_0_52_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_52_Closed_Text.style.display='none'; Codehighlighter1_0_52_Open_Image.style.display='inline'; Codehighlighter1_0_52_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN id=Codehighlighter1_0_52_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_0_52_Open_Text><SPAN style="COLOR: #008080">/*</SPAN><SPAN style="COLOR: #008080"> DO NOT EDIT THIS FILE - it is machine generated </SPAN><SPAN style="COLOR: #008080">*/</SPAN></SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#include </SPAN><SPAN style="COLOR: #808080"><</SPAN><SPAN style="COLOR: #000000">jni.h</SPAN><SPAN style="COLOR: #808080">></SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_71_103_Open_Image onclick="this.style.display='none'; Codehighlighter1_71_103_Open_Text.style.display='none'; Codehighlighter1_71_103_Closed_Image.style.display='inline'; Codehighlighter1_71_103_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_71_103_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_71_103_Closed_Text.style.display='none'; Codehighlighter1_71_103_Open_Image.style.display='inline'; Codehighlighter1_71_103_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_71_103_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_71_103_Open_Text><SPAN style="COLOR: #008080">/*</SPAN><SPAN style="COLOR: #008080"> Header for class HelloWorld </SPAN><SPAN style="COLOR: #008080">*/</SPAN></SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"><FONT size=2> 4</FONT></SPAN><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#ifndef _Included_HelloWorld<BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#define _Included_HelloWorld<BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#ifdef __cplusplus<BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>extern "C" {<BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#endif<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_203_291_Open_Image onclick="this.style.display='none'; Codehighlighter1_203_291_Open_Text.style.display='none'; Codehighlighter1_203_291_Closed_Image.style.display='inline'; Codehighlighter1_203_291_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_203_291_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_203_291_Closed_Text.style.display='none'; Codehighlighter1_203_291_Open_Image.style.display='inline'; Codehighlighter1_203_291_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_203_291_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN></FONT><SPAN id=Codehighlighter1_203_291_Open_Text><SPAN style="COLOR: #008080"><FONT size=2>/*</FONT></SPAN><SPAN style="COLOR: #008080"><BR></SPAN><SPAN style="COLOR: #008080"><FONT size=2>11</FONT></SPAN><FONT size=2><SPAN style="COLOR: #008080"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Class:     HelloWorld<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN></FONT><FONT size=2><SPAN style="COLOR: #008080"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Method:    SayHello<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN></FONT><FONT size=2><SPAN style="COLOR: #008080"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Signature: (Ljava/lang/String;)<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #008080"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top> </SPAN><SPAN style="COLOR: #008080">*/</SPAN></FONT></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"><FONT size=2>15</FONT></SPAN><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>JNIEXPORT void JNICALL Java_HelloWorld_SayHello<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>  (JNIEnv </SPAN><SPAN style="COLOR: #808080">*</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000">, jobject, jstring);<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">18</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#ifdef __cplusplus<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>}<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#endif<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#endif<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></FONT></DIV><FONT size=2>  4,   ~写HelloWorld.cpp<BR></FONT> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><FONT size=2><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">windows.h</SPAN><SPAN style="COLOR: #000000">></SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#include </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">HelloWorld.h</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">stdio.h</SPAN><SPAN style="COLOR: #000000">></SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">与Hello.h中函数声明相?/SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">JNIEXPORT </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> JNICALL Java_HelloWorld_SayHello (JNIEnv </SPAN><SPAN style="COLOR: #000000">*</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"> env, jobject arg, jstring instring)<BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_176_427_Open_Image onclick="this.style.display='none'; Codehighlighter1_176_427_Open_Text.style.display='none'; Codehighlighter1_176_427_Closed_Image.style.display='inline'; Codehighlighter1_176_427_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_176_427_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_176_427_Closed_Text.style.display='none'; Codehighlighter1_176_427_Open_Image.style.display='inline'; Codehighlighter1_176_427_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_176_427_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN></FONT><SPAN id=Codehighlighter1_176_427_Open_Text><FONT size=2><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">从instring字符串取得指向字W串UTF~码的指?/SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">  </SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> jbyte </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">str </SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   (</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> jbyte </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">)env</SPAN><SPAN style="COLOR: #000000">-></SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000">GetStringUTFChars( instring, JNI_FALSE );<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">HelloWorld,%s\n</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000">,str);<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">通知虚拟机本C码不再需要通过str讉KJava字符丌Ӏ?/SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=2><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">env</SPAN><SPAN style="COLOR: #000000">-></SPAN><SPAN style="COLOR: #000000">ReleaseStringUTFChars( instring, (</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">*</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000">)str );<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">return</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></FONT></SPAN><FONT size=2><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">int</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"> WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_506_526_Open_Image onclick="this.style.display='none'; Codehighlighter1_506_526_Open_Text.style.display='none'; Codehighlighter1_506_526_Closed_Image.style.display='inline'; Codehighlighter1_506_526_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_506_526_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_506_526_Closed_Text.style.display='none'; Codehighlighter1_506_526_Open_Image.style.display='inline'; Codehighlighter1_506_526_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_506_526_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN></FONT><SPAN id=Codehighlighter1_506_526_Open_Text><FONT size=2><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN></FONT><FONT size=2><SPAN style="COLOR: #000000"> TRUE ;<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></FONT></SPAN></DIV><FONT size=2>5,  在vc6下新建dll工程HelloWorld,加蝲HelloWorld.h和HelloWorld.cpp,~译生成HelloWorld.dll文gQ最关键的是引用JAVAHOME\include\和JAVAHOME\include\win32?h文g?BR>6Q设|classpath为dll文g所在\径,新徏一个测试类TestHelloWorldDLL.java<BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">1</SPAN><IMG id=Codehighlighter1_24_134_Open_Image onclick="this.style.display='none'; Codehighlighter1_24_134_Open_Text.style.display='none'; Codehighlighter1_24_134_Closed_Image.style.display='inline'; Codehighlighter1_24_134_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_24_134_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_24_134_Closed_Text.style.display='none'; Codehighlighter1_24_134_Open_Image.style.display='inline'; Codehighlighter1_24_134_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> HelloWorld </SPAN><SPAN id=Codehighlighter1_24_134_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_24_134_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_64_132_Open_Image onclick="this.style.display='none'; Codehighlighter1_64_132_Open_Text.style.display='none'; Codehighlighter1_64_132_Closed_Image.style.display='inline'; Codehighlighter1_64_132_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_64_132_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_64_132_Closed_Text.style.display='none'; Codehighlighter1_64_132_Open_Image.style.display='inline'; Codehighlighter1_64_132_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String args[])</SPAN><SPAN id=Codehighlighter1_64_132_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_64_132_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        HelloWorld hw </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> HelloWorld();<BR></SPAN><SPAN style="COLOR: #008080">4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        hw.SayHello(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Christmas</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);    <BR></SPAN><SPAN style="COLOR: #008080">5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV><BR>7,  输出l果: HelloWorld Christmas<BR>=======================================================================================================<BR><BR> <STRONG>接下来,在linux下调用so试一试?BR></STRONG> 因ؓlinux下不能用vc所以gccQ如下命令:<BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">#</SPAN><SPAN style="COLOR: #008000">gcc -I/usr/java/include -shared -o libHelloWorld.so HelloWorld.cpp </SPAN></DIV>    q行试E序Q发C能导?so文gQ提Cno HelloWorld  in java.library.pathQ所以需要设|java.library.path?BR>  <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">java </SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">Djava</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">library</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">path</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">`pwd` </SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">cp </SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">  MyNative</SPAN></DIV>注意我把.so文g拷到了当前\径,其他路径讄卛_Q?BR>再执行,ok了,输出正确l果Q?BR> <BR><STRONG>最后,ȝ一下:<BR></STRONG>  jni的用很单,ȝ的是抽象出所调用dll或so文g的接口封装成nativeҎ。另外就是生成so或dll文g以后的\径很不好控制。最重要的一点Java 的C调用通常不能UL到其他^CQ失M“write onceQrun anywhere ”的誉Q但没违反重用性的规则。再者,需求来了,不这样实现能行吗Q?/FONT><img src ="http://www.aygfsteel.com/beyondduke/aggbug/24983.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/beyondduke/" target="_blank">beyondduke</a> 2005-12-21 18:54 <a href="http://www.aygfsteel.com/beyondduke/archive/2005/12/21/24983.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WebServiceȝhttp://www.aygfsteel.com/beyondduke/archive/2005/12/17/24345.htmlbeyonddukebeyonddukeSat, 17 Dec 2005 05:11:00 GMThttp://www.aygfsteel.com/beyondduke/archive/2005/12/17/24345.htmlhttp://www.aygfsteel.com/beyondduke/comments/24345.htmlhttp://www.aygfsteel.com/beyondduke/archive/2005/12/17/24345.html#Feedback0http://www.aygfsteel.com/beyondduke/comments/commentRss/24345.htmlhttp://www.aygfsteel.com/beyondduke/services/trackbacks/24345.html什么是WebService
     1QWeb Service 是一U新的web应用E序分支Q他们是自包含、自描述、模块化的应用,可以发布、定位、通过web调用。Web Service可以执行从简单的h到复杂商务处理的M功能。一旦部|以后,其他Web Service应用E序可以发现q调用它部v的服务?Web Service是一U应用程序,它可以用标准的互联|协议,像超文本传输协议(HTTP)和XMLQ将功能U领性地体现在互联网和企业内部网上。可Web服务视作Web上的lg~程?nbsp;
       2Qwebq泛用到的技术: 
   ?TCP/IPQ通用|络协议Q被各种讑֤使用 
   ?HTMLQ通用用户界面Q可以用HTML标签昄数据 
   ?JavaQ写一ơ可以在M地方q行的通用~程语言 
   ?XML Q通用数据表达语言Q在web上传送机构化数据的容易方?nbsp;
他们的特Ҏ其开放性,跨^台性,开放性正是Web services的基?
       3QwebService的作?BR>   ?内容更加动态:一个web service必须能合q从多个不同源来的内容,可以包括股票Q天气,新闻{,在传l环境中的内容,如存货水qI购物订单或者目录信息等Q都从后端系l而来
   ?带宽更加便宜Qweb services可以分发各种cd的内容(音频Q视频流{)
   ?存储更便? web services必须能聪明地处理大量数据Q意味着要用数据库QLDAP目录Q缓Ԍ和负载^衡Y件等技术保持可扩展能力
   ◆普遍式计算更重要:web services不能要求客户使用某一版本的windows的传l浏览器Q必L持各U设备,q_Q浏览器cdQ各U内容类型?
       4 Q?webService的实?BR>   ?XML XML是在web上传送结构化数据的伟大方式,Web services要以一U可靠的自动的方式操作数据,HTML不会满要求Q而XML可以使web services十分方便的处理数据,它的内容与表C的分离十分理想
   ?SOAP SOAP使用XML消息调用q程ҎQ这样web services可以通过HTTP协议的post和getҎ与远E机器交互,而且QSOAP更加健壮和灵zL用?
其他象UDDI和WSDL技术与XML和SOAP技术紧密结合用于服务发现?/T

  
II  什么时候用WebService

   ?nbsp; 跨越防火墙的通信
    如果你的应用E序有成千上万的用户Q而且他们都分布在世界各地Q那么客L和服务器之间的通信是一个棘手的问题。那是因为客L和服务器之间通常都会有防火墙或者代理服务器。在q种情况下,你想使用DCOM׃是那么简单了Q而且Q通常你也不愿意把你的客户端程序发布到如此庞大数量的每一个用h中。于是,你最l选择了用览器作为客LQ写下一堆ASP面Q把应用E序的中间层暴露l最l用戗结果呢Q运气好的话Q只是开发难度大了一些,q气不好的话Q就会得C个根本无法维护的应用E序。想象一下你应该怎么在你的应用程序里面加入一个新的页面:你必d建立好用L?Web面)Q以及在q个面后面Q包含相应商业逻辑的中间层lg。这q不够,你还要再建立臛_一个ASP面Q用来接受用戯入的信息Q调用中间层lgQ把l果格式化ؓHTML形式Q最后还要把"l果?送回览器。要是客L代码不再如此依赖于HTML表单Q客L的编E不q单多了吗Q还有,建立ASP面的那一步可以省略掉吗? 当然。如果你的中间层lg是Webservice的话Q你完全可以从用L面直接调用中间层lgQ从而省掉徏立ASP面的那一步。要调用WebserviceQ你可以直接使用MicrosoftSOAPToolkit?NETq样的SOAP客户端,也可以用你自己开发的SOAP客户端,然后把它和你的应用程序连接v来。这样做Q不仅可以羃短开发周期,q可以减代码的复杂度,q增强整个应用程序的可维护性。同Ӟ你的应用E序也不再需要在每次调用中间层组件时Q都跌{到相应的"l果?了。以我的l验来看Q在一个用L面和中间层有较多交互的应用程序中Q用Webserviceq种l构Q可以轻杄节省花在用户界面~程上的20%的开发时间。这样做q有另一个好处,是你将得到一个由Webservicel成的中间层Q这一层是完全可以在应用程序集成或其他场合下被重用的。最后,通过Webservice把你的应用程序的逻辑和数据暴露出来,q可以让其它q_上的客户重用你的应用E序?BR> ?应用E序集成
    企业U的应用E序开发者都知道Q企业里l常都要把用不同语言写成的在不同q_上运行的各种E序集成hQ而这U集成将p很大的开发的力量。你的应用程序经帔R需要从q行在古老的IBML上的E序中获取数据;或者再把数据发送到L或UNIX应用E序中去。即使是在同一个^CQ不同的软g厂商生的各UY件也常常需要集成v来。通过WebserviceQ应用程序可以用标准的方法把功能和数据暴露出来,供其它的应用E序使用。例如,你有一个订单登录程序,用于d从客h的新订单Q包括客户信息、发货地址、数量、h格和付款方式{信息。同Ӟ你还有一个订单执行程序,用于实际货物发送的理。这两个E序是来自不同Y件厂商的。一份新订单q来之后Q订单登录程序需要通知订单执行E序发送货物。通过在订单执行程序上面增加一层WebserviceQ订单执行程序可以把"AddOrder"函数暴露出来。这P每当有新订单到来Ӟ订单dE序可以调用这个函数来发送货物了。进而通过Webservice集成应用E序
  ?B2B的集?BR> 用Webservice集成应用E序Q可以你公司内部的商务处理更加自动化。但当交易跨了你的供应商和客户Q突破了公司的界U时又会怎么样呢Q跨公司的商务交易集成通常叫做B2B集成。Webservice是B2B集成成功的关键。通过WebserviceQ你的公司可以把关键的商务应用暴露给指定的供应商和客戗例如,把你的电子下单系l和电子发票pȝ暴露出来Q你的客户就可以以电子的方式向你发送购货订单,而你的供应商则可以以电子的方式把原料采购的发发送给你。当Ӟqƈ不是一个新的概念:电子文档交换(EDI)早就是这样了。Webservice和EDI之间的主要区别在于,Webservice的实现要比EDI单得多,而且Webservice是运行在Internet上的Q在世界M地方都可L实现Q这样其q行成本q对较低。不q,Webserviceq不像EDI那样Q是文档交换或B2B集成的一套完整的解决Ҏ。Webservice只是B2B集成的一个关键部分,q需要许多其它的部分才能完成q个集成。用Webservice来实现B2B集成的最大好处在于可以轻易实C操作性。只要把你的商务逻辑暴露出来Q成为WebserviceQ你可以让M指定的合作伙伴轻杄调用你的商务逻辑Q而不他们的pȝ在什么^Cq行Q用的是什么开发语a。这样就大大减少了花在B2B集成的上的时间和成本。这L低成本让许多原本无法承受EDI的投资成本的中小企业也能实现B2B集成?BR> ?软g重用
   软g重用是一个很大的主题Q它有很多的形式和程度。最基本的Ş式是源代码模块或者类一U的重用。另一UŞ式是二进制Ş式的lg重用。当前,像表格控件或用户界面控gq样的可重用软glg在市Z都占有很大的份额。但q类软g的重用都有一个很严重的限Ӟ重用仅限于代码,而数据不能被重用。原因在于你可以很轻易的发布lg甚至源代码,但要发布数据没那么Ҏ了,除非那些数据都是不会l常变化的静态数据?nbsp; 而Webservice允许你在重用代码的同Ӟ重用代码后面的数据。用WebserviceQ你不再像以前那P要先从第三方购买、安装Y件组Ӟ再从你的应用E序中调用这些组件。你只需要直接调用远端的Webservice可以了。D个例子,你想在你的应用程序中认用户输入的邮件地址Q那么,你只需把这个地址直接发送给相应的WebserviceQ这个Webservice׃帮你查阅街道地址、城市、省区和邮政~码{信息,认q个地址的确在相应的邮政~码区域。Webservice的提供商可以按时间或使用ơ数来对q项服务q行收费。这L服务要通过lg重用来实现是不现实的Q因为那L话你必须下蝲q安装好包含街道地址、城市、省区和邮政~码{信息的数据库,而且q个数据库还是不能实时更新的。另一UY仉用的情况是把好几个应用程序的功能集成h。例如,你想要徏立一个局域网上的门户站点应用Q让用户既可以查询他们的联邦快递包裹,察看股市行情Q又可以理他们的日E安排,q可以在U购买电q。现在Web上有很多应用E序供应商,都在其应用中实现了上面的q些功能。一旦他们把q些功能都通过Webservice暴露出来Q你可以非常轻易地把所有这些功能都集成C的门L点中Qؓ用户提供一个统一的、友好的界面?BR>用Webservice来集成各U应用中的功能,为用h供一个统一的界?BR>许多应用E序都会利用WebserviceQ把当前Zlg的应用程序结构扩展ؓlg和Webservice的؜合结构。你也可以在应用E序中用第三方的Webservice提供的功能。你q可以把你自q应用E序的功能通过Webservice提供l别人。所有这些情况下Q你都可以重用代码和代码后面的数据。MQWebservice是软g重用的一U非常有力的形式?/FONT>







beyondduke 2005-12-17 13:11 发表评论
]]>单EXCEL报表ҎQSpring+POIhttp://www.aygfsteel.com/beyondduke/archive/2005/12/15/23978.htmlbeyonddukebeyonddukeThu, 15 Dec 2005 02:05:00 GMThttp://www.aygfsteel.com/beyondduke/archive/2005/12/15/23978.htmlhttp://www.aygfsteel.com/beyondduke/comments/23978.htmlhttp://www.aygfsteel.com/beyondduke/archive/2005/12/15/23978.html#Feedback6http://www.aygfsteel.com/beyondduke/comments/commentRss/23978.htmlhttp://www.aygfsteel.com/beyondduke/services/trackbacks/23978.html    q期为完成一个简单的报表模块Q需求很单,从数据库中取出数据导出到已写好的Excel模版中?BR>     一开始准备用jfreeReport实现Q偶然调试spring的demo时发玎ͼcountries的例子很好,既有web分页Q又有excelQpdf的输出,l分析例子,spring装了poi实现excel导出Qitext实现pdf输出?BR>     1Q先来分析一下poi的一些背景。POI的主:http://jakarta.apache.org/poi。POI HSSF是当今市面上最强大的处理EXCEL表格的java工具Q比韩国人写的那个JExcelApi或其它几U工具都要好。而且它是Apache的开源项目。当然POI HSSF也有~点Q不能直接支持EXCEL图表QAPI文档_糙略,有些cdҎ需要引用Apache目中的其它一些包Q包与包之间依赖关系比较复杂{等?BR>Apache的Jakata目的POI子项目,目标是处理ole2对象。目前比较成熟的是HSSF接口Q处理MS ExcelQ?7-2002Q对象。它不象我们仅仅是用csv生成的没有格式的可以由Excel转换的东西,而是真正的Excel对象Q你可以控制一些属性如sheet,cell{等。这是一个年ȝ目Q所以象HDFq样直接支持Word对象的好东西仍然在设计中。其它支持word格式的纯javaҎq有itextQ不q也是仍在奋斗中。但是HSSF已经成熟到能够和_我们使用了。另外,无锡怸Office的实现方案也是纯java的解x案,不过那也是完全商业的产品Qƈ不是公开代码目。其实,从开发历史的角度Ԍ?0q代中期starOffice的原作者在德国成立了StarOffice suite公司Q然后到1999q夏天starOffice被sun收购Q再?000q?月starOffice5.2的发布;q且从starOffice6.0开始,starOffice建立在OpenOffice的api的基上,q个公开代码的office目已经q行了很长的旉。虽焉是由C++写的Q但是POI的代码部分也是由openOffice改过来的。所以,应该对POI充满_的信心。国内已l有部分公司在他们的办公自动化等Web目中用poi了,如日恒的iofficeQv泰的HTOffice{。java当初把核心处理设成UnicodeQ带来的好处是另代码适应了多语言环境。然而由于老外的英语只?6个字母,有些情况下,一些程序员?位的byte处理Q一不小心就L了CJK的高位。或者是׃习惯在程序中采用编码,q有多种原因Q得许多java应用在CJK的处理上很烦恹{还好在POI HSSF中考虑到这个问题,可以讄encoding为双字节。编译好的jar主要有这?个:poi?poi Browser?poi hdf?poi hssf例程包。实际运行时Q需要有poi包就可以了。如果用Jakarta ant~译和运行,下蝲apache Jakarta POI的release中的src包,它里面已lؓ你生成好了build文g了。只要运行ant可以了(ant 的安装和使用在此不说?。如果是用Jbuilder q行Q请在新建的目中加入poi包。以Jbuilder6ZQ选择Tools菜单的config libraries...选项Q新Z个lib。在弹出的菜单中选择poi包,如这个jakarta-poi-1.5.1-final-20020820.jarQ把poid到jbuilder中。然后,右键点击你的目Q在project的properties菜单中path的required Libraries中,点addQ添加刚才加入到jbuilder中的poiC现在的项目中。如果你仅仅是ؓ了熟悉POI hssf的用,可以直接看POI的samples包中的源代码Qƈ且运行它。hssf的各U对象都有例E的介绍。hssf提供的例E在org.apache.poi.hssf.usermodel.examples包中Q共?4个,生成的目标xls都是workbook.xls。如果你想看更多的例E,可以参考hssf的Junit test casesQ在poi的包的源代码中有。hssf都有试代码?BR>     2 Qpoi提供了一个不错的tutorQ教初学者如何快速上手用POI HSSFQ?U>http://jakarta.apache.org/poi/hssf/quick-guide.html
 Z个poiDemo的工E,然后把tutor首页的例子运行一遍,入门U别够了。其中包括:新徏excel文gQWorkBookQ;新徏sheetQ开辟cellQ设|cell数据cd和格式;讄输出的样式如寚w方式Q颜Ԍ字体Q边框等Q合q单元格Q读取已有excel文gQ设|打印区域;讄늠和页脚;调用公式Q选中sheetQ屏q羃放;l图Q插入图像等{?BR>   3Q?spring的对poi的封装。在spring-framework-1.2-rc2\src\org\springframework\web\servlet\view\document下有两个cAbstractExcelView.java和AbstractPdfView.javaQ其中前者是处理excel的抽象类Q承它的时候,需要实现抽象方?!--StartFragment -->buildExcelDocument,实例代码如下Q?/FONT>

 1 protected void buildExcelDocument(
 2
     Map model, HSSFWorkbook workbook,
 3     HttpServletRequest request, HttpServletResponse response) 
{
 4

 5   //
 Go to the first sheet.
 6   //
 getSheetAt: only if workbook is created from an existing document
 7         // HSSFSheet sheet = workbook.getSheetAt(0);

 8         HSSFSheet sheet = workbook.createSheet("Spring");
 9         sheet.setDefaultColumnWidth(12
);
10

11   // Write a text at A1.

12   HSSFCell cell = getCell(sheet, 00);
13   setText(cell, "Spring POI test"
);
14

15   // Write the current date at A2.

16   HSSFCellStyle dateStyle = workbook.createCellStyle();
17   dateStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy"
));
18   cell = getCell(sheet, 10
);
19   cell.setCellValue(new
 Date());
20
   cell.setCellStyle(dateStyle);
21

22   // Write a number at A3

23   getCell(sheet, 20).setCellValue(458);
24

25   // Write a range of numbers.

26   HSSFRow sheetRow = sheet.createRow(3);
27   for (short i = 0; i < 10; i++
{
28     sheetRow.createCell(i).setCellValue(i * 10
);
29   }

30 }
4Q?通过webE序调用Q很多情况需要把生成的excel文g通过|络q接来输出,q些spring已经替你做好了,所以只要按照spring的调用标准就可以Q我使用的是spring的mvcQ实例代码如下:
1protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
2        List list = (List) request.getSession().getAttribute("list"); //从session中取数据list
3        Map model=new HashMap(); 
4        model.put("list",list); //list装传到excelView?/SPAN>
5        ExcelView ev = this.getExcelView();//ExcelViewl承了AbatractExcelView
6         return new ModelAndView(ev,model); //跌{面
7    }
ok,整个单的q程完成了Q你可以Ҏ自己的需求灵zȝ在各个环节codingQ漂亮的报表会让你兴奋不Ԍ




beyondduke 2005-12-15 10:05 发表评论
]]>
https相关http://www.aygfsteel.com/beyondduke/archive/2005/11/04/18076.htmlbeyonddukebeyonddukeFri, 04 Nov 2005 01:21:00 GMThttp://www.aygfsteel.com/beyondduke/archive/2005/11/04/18076.htmlhttp://www.aygfsteel.com/beyondduke/comments/18076.htmlhttp://www.aygfsteel.com/beyondduke/archive/2005/11/04/18076.html#Feedback0http://www.aygfsteel.com/beyondduke/comments/commentRss/18076.htmlhttp://www.aygfsteel.com/beyondduke/services/trackbacks/18076.html什么是HTTPSQ?BR>当?ZSSL/TLSQ通常使用 https:// URLQ向站点q行HTTPhӞ从服务器向客h发送一个证书。客h使用已安装的公共证书通过q个证书验证服务器的w䆾Q然后检?IP 名称Q机器名Q与客户接的机器是否匚w。客h生成一些可以用来生成对话的U钥Q称Z话密钥)的随Z息,然后用服务器的公钥对它加密ƈ它发送到服务器。服务器用自qU钥解密消息Q然后用该随Z息派生出和客h一LU有会话密钥。通常在这个阶D?RSA 公钥法。然后,客户机和服务器用私有会话密钥和U钥法Q通常?RC4Q进行通信。用另一个密钥的消息认证码来保消息的完整性?BR>
什么是数字{֐Q?/STRONG>
所谓数字签名就是信息发送者用其私有密钥对从所传报文中提取出的特征数据Q或U数字指U)q行RSA法操作Q以保证发信人无法抵赖曾发过该信息(即不可抵赖性)Q同时也保信息报文在经{֐后末被篡改(卛_整性)。当信息接收者收到报文后Q就可以用发送者的公钥Ҏ字签名进行验证?BR>
Overview of SSLQ?BR>     SSL, or Secure Socket Layer, is a technology which allows web browsers and web servers to communicate over a secured connection. This means that the data being sent is encrypted by one side, transmitted, then decrypted by the other side before processing. This is a two-way process, meaning that both the server AND the browser encrypt all traffic before sending out data.
     Another important aspect of the SSL protocol is Authentication. This means that during your initial attempt to communicate with a web server over a secure connection, that server will present your web browser with a set of credentials, in the form of a "Certificate", as proof the site is who and what it claims to be. In certain cases, the server may also request a Certificate from your web browser, asking for proof that you are who you claim to be. This is known as "Client Authentication," although in practice this is used more for business-to-business (B2B) transactions than with individual users. Most SSL-enabled web servers do not request Client Authentication.
https与Tomcat
   The Apache Jakarta Tomcat 5 Servlet/JSP Container SSL Configuration HOW-TO?
利用快速配|:
  1Q用jdk中的keytool生成一个tomcat keystore
    在命令行敲入Q?JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
    会提CZ输入keypassword ?keystorepassword 以及其它相关信息。按提示认完成?BR>  2Q?在conf/server.xml中加入:
    
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" debug="0" scheme="https" secure="true"
               clientAuth="false" keystorePass="password" sslProtocol="TLS" />
 
3Q启动tomcat,打开览器输?/FONT>https://localhost:8443 OK了?BR>注意Q用此方法生成的keystore文g|于C:\Documents and Settings\user?BR>注释Q?CONNECTOR />
Attribute Description
clientAuth Set this value to true if you want Tomcat to require all SSL clients to present a client Certificate in order to use this socket. Set this value to want if you want Tomcat to request a client Certificate, but not fail if one isn't presented.
keystoreFile Add this attribute if the keystore file you created is not in the default place that Tomcat expects (a file named .keystore in the user home directory under which Tomcat is running). You can specify an absolute pathname, or a relative pathname that is resolved against the $CATALINA_BASE environment variable.
keystorePass Add this element if you used a different keystore (and Certificate) password than the one Tomcat expects (changeit).
keystoreType Add this element if using a PKCS12 keystore. The valid values are JKS and PKCS12.
sslProtocol The encryption/decryption protocol to be used on this socket. It is not recommended to change this value if you are using Sun's JVM. It is reported that IBM's 1.4.1 implementation of the TLS protocol is not compatible with some popular browsers. In this case, use the value SSL.
ciphers The comma separated list of encryption ciphers that this socket is allowed to use. By default, any available cipher is allowed.
algorithm The X509 algorithm to use. This defaults to the Sun implementation (SunX509). For IBM JVMs you should use the value IbmX509. For other vendors, consult the JVM documentation for the correct value.
truststoreFile The TrustStore file to use to validate client certificates.
truststorePass The password to access the TrustStore. This defaults to the value of keystorePass.
truststoreType Add this element if your are using a different format for the TrustStore then you are using for the KeyStore. The valid values are JKS and PKCS12.

Java keytool工具的作用及使用Ҏ?
Keytool 是安全钥匙与证书的管理工兗它理一个存储了U有钥匙和验证相应公共钥匙的与它们相兌的X.509 证书铄keystore(相当一个数据库)?BR>Keytool 是一个有效的安全钥匙和证书的理工具。它能够使用户用数字签名来理他们自己的私?公共钥匙?理用来作自我鉴定的相关的证?理数据完整性和鉴定服务。它q能使用户在通信时缓存它们的公共钥匙.
一个证书是某一实体(个h,公司{?的数字签名,指出其他实体的公共钥?或其他信?的详l的?当数据被{֐?q个{֐信息被用来检验数据的完整性和真实?完整性指数据没有被修改和改,真实性指数据从Q何生和{֐的一方真正的传输到达?BR>Keytool 把钥匙和证书储存C个keystore.默Q的实现keystore的是一个文件。它用一个密码保护钥匙。而另外的一个工具jarsigner用keystore中的信息产生或检验Java aRchive(jar文g)中的数字{֐?BR>Keystore有两个不同的入口:
1.       钥匙入口:保存了非常敏感的加密的钥匙信?q且是用一个保护的格式存储以防止未被授权的讉K.以这UŞ式存储的钥匙是秘密钥?或是一个对应证书链中公有钥匙的U有钥匙.
2.    信Q证书入口:包含一个属于其他部分的单一公共钥匙证书.它之所以被UCؓ"信Q证书",是因为keystore信Q的证书中的公共钥匙真正属于证书所有者的w䆾识别.
 
Keystore的别?
所有的keystore入口(钥匙和信任证书入?是通过唯一的别名访?别名是不区分大小写的。如别名Hugo和hugo指向同一个keystore入口.
可以在加一个入口到keystore的时候?genkey参数来生一个钥匙对(公共钥匙和私有钥?时指定别?也可以用-import参数加一个证书或证书铑ֈ信Q证书?BR> 
如:keytool -genkey -alias duke -keypass dukekeypasswd
 
其中duke为别?dukekeypasswd为duke别名的密码。这行命令的作用是生一个新的公?U有钥匙? 其中duke为别?dukekeypasswd为duke别名的密?q行命o的作用是产生一个新的公?U有钥匙?
假如你想修改密码,可以用:
keytool -keypasswd -alias duke -keypass dukekeypasswd -new newpass
旧密码dukekeypasswd改ؓnewpass.
 
Keystore的?
1.       当?genkey ?import?identitydb命od数据C个keystore,而当q个keystore不存在时,产生一个keystore.默认名是.keystore,存放到user-home目录.
2.    当用-keystore指定?生指定的keystore.
 
Keystore的实?
Keytool cM于java.security包下,提供一个非常好的接口去取得和修改一个keystore中的信息. 目前有两个命令行:keytool和jarsinger,一个GUI工具Policy 可以实现keystore.׃keystore是公开?用户可以用它写一些额外的安全应用E序?BR>Keystoreq有一个sun公司提供的內在实?它把keystore作ؓ一个文件来实现.利用了一个keystorecd(格式)"JKS".它用单独的密码保护每一个私有钥?也用可能不同的密码保护整个keystore的完整?
 
支持的算法和钥匙大小:
keytool允许用户指定钥匙对和注册密码服务供应者所提供的签名算?~省的钥匙对产生法?DSA"。假如私有钥匙是"DSA"cdQ缺省签名算法是"SHA1withDSA"Q假如私有钥匙是"RSA"cd,~省法?MD5withRSA".
当生一个DSA钥匙?钥匙必须?12-1024位之?对Q何算法的~省钥匙大小?024?
 
1.       证书Q一个证书是一个实体的数字{֐,指出其他实体的公共钥匙有明确的倹{?BR>2.       公共钥匙Q是同一个详l的实体的数字关?q有意让所有想同这个实体发生信dpȝ其他实体知道Q公共钥匙用来检验签?
3.    数字{֐:假如数据已被{֐,q用w䆾存储在一个实体中,一个签名能够证明这个实体知道这个数?q个数据用实体私有钥匙签名ƈ递交;
4.    w䆾:知道实体的方?在一些系l中w䆾是公共钥?其他pȝ中可以是从一个X.509名字的邮件地址的Unix UID来的M东西;
5.    {֐:一个签名用实体U有钥匙来计某些加密数?
6.    U有钥匙:是一些数?每一个私有钥匙只能被特定的拥有该U有钥匙的实体知?U有和公共钥匙存在所有用公共钥匙加密的系l的钥匙对中.一个公共钥匙加?如DSA),一个私有钥匙与一个正的公共钥匙通信.U有钥匙用来计算{֐?BR>7.    实体:一个实体可以是一个h,一个组l?一个程?一台计机,一个商?一个银?或其他你想信ȝ东西.
 
Keytool应用实例:
 
1.产生一个keystore:
 
keytool -genkey -alias User(keystore的别? -keyalg RSA -validity 7 -keystore keystore(指定keystore).
 
q行q个命o,pȝ提示:
Enter keystore password:yourpassword(输入密码)
 
What is your first and last name?
[Unknown]: your name(输入你的名字)
 
What is the name of your organizational unit?
[Unknown]:your organizational(输入你所在组l单位的名字)
 
What is the name of your organization?
[Unknown]:your organization name (输入你所在组l的名字)
 
What is the name of your City or Locality?
[Unknown]:your city name(输入所在城市的名字)
 
What is the name of your State or Province?
[Unknown]:your provice name(输入所在省份名?
 
What is the two-letter country code for this unit?
[Unknown]:cn(输入国家名字)
Is CN=your name, OU=your organizaion, O="your organization name",L=your city name, ST=your province name, C=cn correct?
[no]: yes
 
3.    查一个keystore:
keytool -list -v -keystore keystore
Enter keystore password:your password(输入密码)
 
显Ckeystore內容?
Keystore type: jks
Keystore provider: SUN
 
Your keystore contains 1 entry
Alias name: yourname
Creation date: Dec 20, 2001
Entry type: keyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=yourname, OU=your organization, O="your organization name",
L=your city name, ST=your province name, C=CN
Issuer: CN=Duke, OU=Java Software, O="Sun Microsystems, Inc.", L=Palo Alto, ST=CA, C=US
Serial number: 3c22adc1
Valid from: Thu Dec 20 19:34:25 PST 2001 until: Thu Dec 27 19:34:25 PST 2001
Certificate fingerprints:
MD5: F1:5B:9B:A1:F7:16:CF:25:CF:F4:FF:35:3F:4C:9C:F0
SHA1: B2:00:50:DD:B6:CC:35:66:21:45:0F:96:AA:AF:6A:3D:E4:03:7C:74
 
3Q输出keystoreC个文?testkey:
keytool -export -alias duke -keystore keystore -rfc -file testkey
pȝ输出QEnter keystore password:your password(输入密码)
Certificate stored in file < td>
 
4Q输入证书到一个新的truststore:
keytool -import -alias dukecert -file testkey -keystore truststore
Enter keystore password:your new password.(输入truststore新密?
 
 
5Q检查truststore:
keytool -list -v -keystore truststore
pȝ显Ctruststore的信?
 
现在可以用适当的keystoreq行你的应用E序.?
java -Djavax.net.ssl.keyStore = keystore
-Djavax.net.ssl.keyStorePassword=password Server
 
?
 java -Djavax.net.ssl.trustStore=truststore
-Djavax.net.ssl.trustStorePassword=trustword Client


beyondduke 2005-11-04 09:21 发表评论
]]> վ֩ģ壺 ׿| ˰| DZɽ| | ĵ| | | | ɽ| Ͻ| Ϸ| | | | ˮ| ɽ| ;| | | Ĵʡ| | ¡| | | | | | | ֹ| ͩ| ͭ| ɳ| | ƽ| º| | | | | ɽ| ƽ|