??xml version="1.0" encoding="utf-8" standalone="yes"?>heyzo在线欧美播放,精品亚洲第一,久久99欧美http://www.aygfsteel.com/birdshover/——\漫O其修q兮Q吾上下而爬楼梯Q?/description>zh-cnThu, 19 Jun 2025 22:28:06 GMTThu, 19 Jun 2025 22:28:06 GMT60一个JNI的问题请?/title><link>http://www.aygfsteel.com/birdshover/archive/2010/04/28/319625.html</link><dc:creator>Birdshover</dc:creator><author>Birdshover</author><pubDate>Wed, 28 Apr 2010 10:11:00 GMT</pubDate><guid>http://www.aygfsteel.com/birdshover/archive/2010/04/28/319625.html</guid><wfw:comment>http://www.aygfsteel.com/birdshover/comments/319625.html</wfw:comment><comments>http://www.aygfsteel.com/birdshover/archive/2010/04/28/319625.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.aygfsteel.com/birdshover/comments/commentRss/319625.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/birdshover/services/trackbacks/319625.html</trackback:ping><description><![CDATA[<div><span style="color: #ff0000; ">q个问题比较急,借用首页发一下,谢谢Q?/span><br /> <br /> 最q需要对一个C++库进行封装,为简单v见决定用JAVA对其装。但是一直调用不成功Q于是写了一D|试代码测试一下。ؓ单v见,׃用默认包了?/div> <br /> <div style="background-color: #eeeeee; font-size: 13px; border-left-color: #cccccc; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> TestDLL {<br />     </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">native</span><span style="color: #000000; "> String Test(String put);<br />     <br />     </span><span style="color: #0000FF; ">static</span><span style="color: #000000; ">{<br />         System.loadLibrary(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">testdll</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />     }<br />     <br />     </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) {    <br />         TestDLL test </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> TestDLL();<br />         System.out.println(test.Test(</span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Date().toString()));<br />     }<br /> }</span></div> <br /> 然后生成了C++头文?br /> <br /> <div style="background-color: #eeeeee; font-size: 13px; border-left-color: #cccccc; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008000; ">/*</span><span style="color: #008000; "> DO NOT EDIT THIS FILE - it is machine generated </span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /> #include </span><span style="color: #000000; "><</span><span style="color: #000000; ">jni.h</span><span style="color: #000000; ">></span><span style="color: #000000; "><br /> </span><span style="color: #008000; ">/*</span><span style="color: #008000; "> Header for class TestDLL </span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /> <br /> #ifndef _Included_TestDLL<br /> </span><span style="color: #0000FF; ">#define</span><span style="color: #000000; "> _Included_TestDLL</span><span style="color: #000000; "><br /> #ifdef __cplusplus<br /> </span><span style="color: #0000FF; ">extern</span><span style="color: #000000; "> </span><span style="color: #000000; ">"</span><span style="color: #000000; ">C</span><span style="color: #000000; ">"</span><span style="color: #000000; "> {<br /> </span><span style="color: #0000FF; ">#endif</span><span style="color: #000000; "><br /> </span><span style="color: #008000; ">/*</span><span style="color: #008000; "><br />  * Class:     TestDLL<br />  * Method:    Test<br />  * Signature: (Ljava/lang/String;)Ljava/lang/String;<br />  </span><span style="color: #008000; ">*/</span><span style="color: #000000; "><br /> JNIEXPORT jstring JNICALL Java_TestDLL_Test<br />   (JNIEnv </span><span style="color: #000000; ">*</span><span style="color: #000000; ">, jobject, jstring);<br /> <br /> #ifdef __cplusplus<br /> }<br /> </span><span style="color: #0000FF; ">#endif</span><span style="color: #000000; "><br /> </span><span style="color: #0000FF; ">#endif</span></div> <br /> 下面是简单的实现<br /> <div style="background-color: #eeeeee; font-size: 13px; border-left-color: #cccccc; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000; ">#include </span><span style="color: #000000; ">"</span><span style="color: #000000; ">TestDLL.h</span><span style="color: #000000; ">"</span><span style="color: #000000; "><br /> <br /> JNIEXPORT jstring JNICALL Java_TestDLL_Test<br />   (JNIEnv </span><span style="color: #000000; ">*</span><span style="color: #000000; ">, jobject, jstring put){<br />       </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> put;<br /> }</span></div> <br /> <span style="color: red; ">在linux下通过gcc~译后,java调用Q?br /> java -Djava.library.path=/home/xp -cp . TestDLL<br /> <br /> 一直报错:</span><br /> <div style="background-color: #eeeeee; font-size: 13px; border-left-color: #cccccc; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; "><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000; ">Exception </span><span style="color: #0000FF; ">in</span><span style="color: #000000; "> thread </span><span style="color: #000000; ">"</span><span style="color: #000000; ">main</span><span style="color: #000000; ">"</span><span style="color: #000000; "> java.lang.UnsatisfiedLinkError: no testdll </span><span style="color: #0000FF; ">in</span><span style="color: #000000; "> java.library.path<br />         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:</span><span style="color: #000000; ">1734</span><span style="color: #000000; ">)<br />         at java.lang.Runtime.loadLibrary0(Runtime.java:</span><span style="color: #000000; ">823</span><span style="color: #000000; ">)<br />         at java.lang.System.loadLibrary(System.java:</span><span style="color: #000000; ">1028</span><span style="color: #000000; ">)<br />         at TestDLL.main(TestDLL.java:</span><span style="color: #000000; ">27</span><span style="color: #000000; ">)</span></div> <br /> <span style="color: red; ">但是我在windows下编译了testdll.dll后,能够调用正常?br /> </span><br /> <span style="color: red; ">接着我改写ؓSystem.load("/home/xp/testdll.so");l果可以在linux使用了,希望有经验的朋友可以解答我的疑问?br /> <br /> <br /> </span> <img src ="http://www.aygfsteel.com/birdshover/aggbug/319625.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/birdshover/" target="_blank">Birdshover</a> 2010-04-28 18:11 <a href="http://www.aygfsteel.com/birdshover/archive/2010/04/28/319625.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>重读Thinking in javahttp://www.aygfsteel.com/birdshover/archive/2009/10/31/300461.htmlBirdshoverBirdshoverSat, 31 Oct 2009 03:51:00 GMThttp://www.aygfsteel.com/birdshover/archive/2009/10/31/300461.htmlhttp://www.aygfsteel.com/birdshover/comments/300461.htmlhttp://www.aygfsteel.com/birdshover/archive/2009/10/31/300461.html#Feedback0http://www.aygfsteel.com/birdshover/comments/commentRss/300461.htmlhttp://www.aygfsteel.com/birdshover/services/trackbacks/300461.htmlThinking in java对承和l合又有了新的认识。对使用用例和用用例P代也有了更深的感(zhn),记录一下?/span>

Birdshover 2009-10-31 11:51 发表评论
]]>
接口型(l构型)模式——适配器模?/title><link>http://www.aygfsteel.com/birdshover/archive/2009/08/13/290981.html</link><dc:creator>Birdshover</dc:creator><author>Birdshover</author><pubDate>Thu, 13 Aug 2009 04:48:00 GMT</pubDate><guid>http://www.aygfsteel.com/birdshover/archive/2009/08/13/290981.html</guid><wfw:comment>http://www.aygfsteel.com/birdshover/comments/290981.html</wfw:comment><comments>http://www.aygfsteel.com/birdshover/archive/2009/08/13/290981.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/birdshover/comments/commentRss/290981.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/birdshover/services/trackbacks/290981.html</trackback:ping><description><![CDATA[<p align="left">接口型模式(Interface PatternQ,有的书上也叫l构型模?Structural Pattern)。适配器模式是其中的一U?br /> <br /> 一、对接口q行适配<br /> <br /> </p> <div align="center"><img height="177" alt="" src="http://www.aygfsteel.com/images/blogjava_net/birdshover/dd.jpg" width="281" border="0" /><br /> <br /> ?.1</div> 如图1.1Q已l存在了ExistsClass实现了想要的功能Q但是,在用时可能无法使用Q因此,把用的条g抽象为Adapter接口Q用AdapterClassl承自ExistsClass同时实现接口Q完成工作?br /> <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 alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff">package</span><span style="color: #000000"> Interface.Adapter;<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img id="Codehighlighter1_53_72_Open_Image" onclick="this.style.display='none'; Codehighlighter1_53_72_Open_Text.style.display='none'; Codehighlighter1_53_72_Closed_Image.style.display='inline'; Codehighlighter1_53_72_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_53_72_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_53_72_Closed_Text.style.display='none'; Codehighlighter1_53_72_Open_Image.style.display='inline'; Codehighlighter1_53_72_Open_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">interface</span><span style="color: #000000"> Adapter </span><span id="Codehighlighter1_53_72_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 alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_53_72_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />    </span><span style="color: #0000ff">void</span><span style="color: #000000"> NewWork();<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div> <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 alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff">package</span><span style="color: #000000"> Interface.Adapter;<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img id="Codehighlighter1_53_113_Open_Image" onclick="this.style.display='none'; Codehighlighter1_53_113_Open_Text.style.display='none'; Codehighlighter1_53_113_Closed_Image.style.display='inline'; Codehighlighter1_53_113_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_53_113_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_53_113_Closed_Text.style.display='none'; Codehighlighter1_53_113_Open_Image.style.display='inline'; Codehighlighter1_53_113_Open_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> ExistsClass </span><span id="Codehighlighter1_53_113_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 alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_53_113_Open_Text"><span style="color: #000000">{<br /> <img id="Codehighlighter1_74_111_Open_Image" onclick="this.style.display='none'; Codehighlighter1_74_111_Open_Text.style.display='none'; Codehighlighter1_74_111_Closed_Image.style.display='inline'; Codehighlighter1_74_111_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_74_111_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_74_111_Closed_Text.style.display='none'; Codehighlighter1_74_111_Open_Image.style.display='inline'; Codehighlighter1_74_111_Open_Text.style.display='inline';" alt="" 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">void</span><span style="color: #000000"> Work()</span><span id="Codehighlighter1_74_111_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 alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_74_111_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(</span><span style="color: #000000">"</span><span style="color: #000000">do work!</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div> <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 alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff">package</span><span style="color: #000000"> Interface.Adapter;<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img id="Codehighlighter1_93_188_Open_Image" onclick="this.style.display='none'; Codehighlighter1_93_188_Open_Text.style.display='none'; Codehighlighter1_93_188_Closed_Image.style.display='inline'; Codehighlighter1_93_188_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_93_188_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_93_188_Closed_Text.style.display='none'; Codehighlighter1_93_188_Open_Image.style.display='inline'; Codehighlighter1_93_188_Open_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> AdapterClass </span><span style="color: #0000ff">extends</span><span style="color: #000000"> ExistsClass </span><span style="color: #0000ff">implements</span><span style="color: #000000"> Adapter </span><span id="Codehighlighter1_93_188_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 alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_93_188_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />    @Override<br /> <img id="Codehighlighter1_130_186_Open_Image" onclick="this.style.display='none'; Codehighlighter1_130_186_Open_Text.style.display='none'; Codehighlighter1_130_186_Closed_Image.style.display='inline'; Codehighlighter1_130_186_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_130_186_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_130_186_Closed_Text.style.display='none'; Codehighlighter1_130_186_Open_Image.style.display='inline'; Codehighlighter1_130_186_Open_Text.style.display='inline';" alt="" 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">void</span><span style="color: #000000"> NewWork() </span><span id="Codehighlighter1_130_186_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 alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_130_186_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="color: #008000">//</span><span style="color: #008000"> TODO Auto-generated method stub</span><span style="color: #008000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #000000">        </span><span style="color: #0000ff">super</span><span style="color: #000000">.Work();<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div> <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 alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff">package</span><span style="color: #000000"> UTest;<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> junit.framework.TestCase;<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> Interface.Adapter.Adapter;<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff">import</span><span style="color: #000000"> Interface.Adapter.AdapterClass;<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /> <img id="Codehighlighter1_165_251_Open_Image" onclick="this.style.display='none'; Codehighlighter1_165_251_Open_Text.style.display='none'; Codehighlighter1_165_251_Closed_Image.style.display='inline'; Codehighlighter1_165_251_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_165_251_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_165_251_Closed_Text.style.display='none'; Codehighlighter1_165_251_Open_Image.style.display='inline'; Codehighlighter1_165_251_Open_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /></span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> TestAdapter </span><span style="color: #0000ff">extends</span><span style="color: #000000"> TestCase </span><span id="Codehighlighter1_165_251_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 alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_165_251_Open_Text"><span style="color: #000000">{<br /> <img id="Codehighlighter1_193_249_Open_Image" onclick="this.style.display='none'; Codehighlighter1_193_249_Open_Text.style.display='none'; Codehighlighter1_193_249_Closed_Image.style.display='inline'; Codehighlighter1_193_249_Closed_Text.style.display='inline';" alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_193_249_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_193_249_Closed_Text.style.display='none'; Codehighlighter1_193_249_Open_Image.style.display='inline'; Codehighlighter1_193_249_Open_Text.style.display='inline';" alt="" 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">void</span><span style="color: #000000"> testNewWork()</span><span id="Codehighlighter1_193_249_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 alt="" src="http://www.aygfsteel.com/Images/dot.gif" /></span><span id="Codehighlighter1_193_249_Open_Text"><span style="color: #000000">{<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        Adapter ada </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> AdapterClass();<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" />        ada.NewWork();<br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span><span style="color: #000000"><br /> <img alt="" src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span></div> <p> </p> <p>二、对cd象进行适配<br /> </p> <div align="center"><img height="180" alt="" src="http://www.aygfsteel.com/images/blogjava_net/birdshover/dd1.jpg" width="280" border="0" /><br /> ?.1</div> <p>和接口匹配差不多Q但对已存在cM是承关p,而是一U关联或依赖?br /> </p> <img src ="http://www.aygfsteel.com/birdshover/aggbug/290981.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/birdshover/" target="_blank">Birdshover</a> 2009-08-13 12:48 <a href="http://www.aygfsteel.com/birdshover/archive/2009/08/13/290981.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>详解JavaBeanhttp://www.aygfsteel.com/birdshover/archive/2009/05/22/277305.htmlBirdshoverBirdshoverFri, 22 May 2009 05:49:00 GMThttp://www.aygfsteel.com/birdshover/archive/2009/05/22/277305.htmlhttp://www.aygfsteel.com/birdshover/comments/277305.htmlhttp://www.aygfsteel.com/birdshover/archive/2009/05/22/277305.html#Feedback0http://www.aygfsteel.com/birdshover/comments/commentRss/277305.htmlhttp://www.aygfsteel.com/birdshover/services/trackbacks/277305.html
先定义一个类
package yurow.jstore;

import java.util.Random;

public class TestClass {
    
private int showCount;
    
    
public TestClass(){
        random 
= new Random().nextInt();
    }
    
    
private int random;
    
    
public String Show(){
        showCount
++;
        String str 
= "random : " + random;
        str
+="<br/>showCount : " + showCount;
        
return str;
    }
}

然后在Default.jsp中调用?br /> <jsp:useBean id="test1" class="yurow.jstore.TestClass" scope="page" />
<%= test1.Show() %>
<br/>
<jsp:useBean id="test2" class="yurow.jstore.TestClass" scope="page" />
<%= test2.Show() %>
在test.jsp同样使用q样的调用方式?br />
而scope一共有"application","page","session","request"四个倹{?br />
一、page
现在的情冉|scope="page" 。其面h。test1和test2的random不一_q且两个面中的也不一致。由此断定:
scope="page"情况下,一个userBean是一ơ实例化的过E?br />
二、request
scope="request"的情况与scope="page" 的一栗?br />
三、session
scope="session"的情况,同一个页面中Qtest1与test2的random不一_可以断定Q这是两个实例。而showCount 会不断篏加,因此q两个实例ƈ不随面的刷新而重新创建。两个不同页面中Qtest1的状态完全一_test2的状态完全一致。这表明Qscope="session"的状态,创徏实例是与id相关的。打开不同览器或者清ICookiesQ将D实例的重新创建。这表明Q当前状态下Q创建实例与session相关Q有个过期的旉?br />
四、application
scope="application"是全局的表C。打开不同览器浏览不同的面Qtest1与test2仍然不一_但是不同面的test1已经一_q且不同览器中数量仍然累加。所以,实例的创Z否,只与id有关?

Birdshover 2009-05-22 13:49 发表评论
]]>
javascript数组与java的数l?/title><link>http://www.aygfsteel.com/birdshover/archive/2009/01/16/251552.html</link><dc:creator>Birdshover</dc:creator><author>Birdshover</author><pubDate>Fri, 16 Jan 2009 03:38:00 GMT</pubDate><guid>http://www.aygfsteel.com/birdshover/archive/2009/01/16/251552.html</guid><wfw:comment>http://www.aygfsteel.com/birdshover/comments/251552.html</wfw:comment><comments>http://www.aygfsteel.com/birdshover/archive/2009/01/16/251552.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/birdshover/comments/commentRss/251552.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/birdshover/services/trackbacks/251552.html</trackback:ping><description><![CDATA[定义一个js的数l?br /> var arr = [<br />                     ["1"],<br />                     ["2"]<br />                 ];<br /> l过java引擎解析后,得到的对象是sun.org......NativeArray<br /> 在我的eclipse中找不到q个cR也没办法直接转换成java数组对象了?br /> <br /> 现在换成在js中用java的数l?br /> var result = new java.awt.List();<br /> result.add("aasdasd");<br /> result.add("123123");<br /> <br /> java解析Q?br />   ScriptEngineManager m = new ScriptEngineManager();<br />   ScriptEngine engine = m.getEngineByExtension("js");<br />   try {<br />    engine.eval(file.getContent());<br />   } catch (ScriptException e) {<br />    System.out.println("执行脚本错误:" + file.getFileName());<br />    return;<br />   }<br />   List o = (List)engine.get(resultKey);<br />   System.out.print(o.getItem(0));<br /> <br /> q样没有问题了? <img src ="http://www.aygfsteel.com/birdshover/aggbug/251552.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/birdshover/" target="_blank">Birdshover</a> 2009-01-16 11:38 <a href="http://www.aygfsteel.com/birdshover/archive/2009/01/16/251552.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java 调用javascript脚本(jre6)http://www.aygfsteel.com/birdshover/archive/2009/01/13/251161.htmlBirdshoverBirdshoverTue, 13 Jan 2009 09:41:00 GMThttp://www.aygfsteel.com/birdshover/archive/2009/01/13/251161.htmlhttp://www.aygfsteel.com/birdshover/comments/251161.htmlhttp://www.aygfsteel.com/birdshover/archive/2009/01/13/251161.html#Feedback4http://www.aygfsteel.com/birdshover/comments/commentRss/251161.htmlhttp://www.aygfsteel.com/birdshover/services/trackbacks/251161.html必须jre6才行Q要不需要用开源库?/p>
package script;

import javax.script.*;
/**
 * Java调用JavaScriptCZ
 * 
 * 
@author Birdshover
 *
 
*/
public final class scriptMaster {
    
/**
     * q行指定脚本
     * 
@return q回脚本?br />      */
    
public int run() {
        ScriptEngineManager m 
= new ScriptEngineManager();
        ScriptEngine engine 
= m.getEngineByExtension("js");
        
try{
            engine.eval(
"var t=1;t++;");
            engine.eval(
"t++;");
        }
catch(ScriptException ex){
            
return -1;
        }
        Float val 
= Float.parseFloat(engine.get("t").toString());
        
return val.intValue();
    }
}

java调用javascript,而javascript内部又调用了java的类库?br />
    public String now(){
        ScriptEngineManager m 
= new ScriptEngineManager();
        ScriptEngine engine 
= m.getEngineByExtension("js");
        
try{
            engine.eval(
"var t= new java.util.Date();");
        }
catch(ScriptException ex){
            
return (new Date()).toString();
        }
        
return engine.get("t").toString();
    }


Birdshover 2009-01-13 17:41 发表评论
]]>
泛型转换cd之C#与JAVA的异?/title><link>http://www.aygfsteel.com/birdshover/archive/2008/12/09/245255.html</link><dc:creator>Birdshover</dc:creator><author>Birdshover</author><pubDate>Tue, 09 Dec 2008 07:18:00 GMT</pubDate><guid>http://www.aygfsteel.com/birdshover/archive/2008/12/09/245255.html</guid><wfw:comment>http://www.aygfsteel.com/birdshover/comments/245255.html</wfw:comment><comments>http://www.aygfsteel.com/birdshover/archive/2008/12/09/245255.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/birdshover/comments/commentRss/245255.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/birdshover/services/trackbacks/245255.html</trackback:ping><description><![CDATA[关于cd转换QC#与JAVA最大的不同在于C#有structQ而JAVA则没有这玩意。于是乎在C#中泛型类型{换就有一下代?仅限structl构)。另外一个较?yu)的差异呢则是在C#中各structcd都带有TryParseҎ(gu)Q当Ӟ2.0以后Q包?.0Q才有?br /> <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: #0000ff">namespace</span><span style="color: #000000"> DObject.DType<br /> {<br />     </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />     </span><span style="color: #808080">///</span><span style="color: #008000"> cd转换帮助c,静态方法实现。加入了~存机制Q减反次数?br />     </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #808080"><br /> </span><span style="color: #000000">    </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">class</span><span style="color: #000000"> StaticConvertor<br />     {<br />         </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">const</span><span style="color: #000000"> </span><span style="color: #0000ff">string</span><span style="color: #000000"> CONVERTMETHOD </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">TryParse</span><span style="color: #000000">"</span><span style="color: #000000">;<br />         </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> Dictionary</span><span style="color: #000000"><</span><span style="color: #000000">System.Type, MethodInfo</span><span style="color: #000000">></span><span style="color: #000000"> map </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> Dictionary</span><span style="color: #000000"><</span><span style="color: #000000">System.Type, MethodInfo</span><span style="color: #000000">></span><span style="color: #000000">(</span><span style="color: #000000">20</span><span style="color: #000000">);<br /> <br />         </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> MethodInfo prepareMethod(System.Type type)<br />         {<br />             </span><span style="color: #0000ff">lock</span><span style="color: #000000"> (map)<br />             {<br />                 </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #000000">!</span><span style="color: #000000">map.ContainsKey(type))<br />                 {<br />                     System.Type[] typeArray </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> System.Type[</span><span style="color: #000000">2</span><span style="color: #000000">];<br />                     typeArray.SetValue(</span><span style="color: #0000ff">typeof</span><span style="color: #000000">(</span><span style="color: #0000ff">string</span><span style="color: #000000">), </span><span style="color: #000000">0</span><span style="color: #000000">);<br />                     typeArray.SetValue(type.GetType().MakeByRefType(), </span><span style="color: #000000">1</span><span style="color: #000000">);<br />                     MethodInfo method </span><span style="color: #000000">=</span><span style="color: #000000"> type.GetType().GetMethod(CONVERTMETHOD, typeArray);<br />                     </span><span style="color: #0000ff">if</span><span style="color: #000000"> (method </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">)<br />                     {<br />                         map.Add(type, method);<br />                     }<br />                     </span><span style="color: #0000ff">else</span><span style="color: #000000"><br />                         </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">;<br />                 }<br />                 </span><span style="color: #0000ff">return</span><span style="color: #000000"> map[type];<br />             }<br />         }    </span><span style="color: #008000">//</span><span style="color: #008000">end prepareMethod</span><span style="color: #008000"><br /> </span><span style="color: #000000"><br /> <br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> 转换Ҏ(gu)<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><typeparam name="T"></span><span style="color: #008000">转换后类?/span><span style="color: #808080"></typeparam></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><param name="raw"></span><span style="color: #008000">原始对象</span><span style="color: #808080"></param></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><param name="defaultValue"></span><span style="color: #008000">默认?/span><span style="color: #808080"></param></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><param name="convertSuccessful"></span><span style="color: #008000">是否转换成功</span><span style="color: #808080"></param></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><returns></span><span style="color: #008000">q回?/span><span style="color: #808080"></returns></span><span style="color: #808080"><br /> </span><span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> T Convert</span><span style="color: #000000"><</span><span style="color: #000000">T</span><span style="color: #000000">></span><span style="color: #000000">(</span><span style="color: #0000ff">object</span><span style="color: #000000"> raw, T defaultValue, </span><span style="color: #0000ff">out</span><span style="color: #000000"> </span><span style="color: #0000ff">bool</span><span style="color: #000000"> convertSuccessful) where T : </span><span style="color: #0000ff">struct</span><span style="color: #000000"><br />         {<br />             convertSuccessful </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">false</span><span style="color: #000000">;<br />             </span><span style="color: #0000ff">if</span><span style="color: #000000"> (raw </span><span style="color: #000000">==</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">) </span><span style="color: #008000">//</span><span style="color: #008000">p|</span><span style="color: #008000"><br /> </span><span style="color: #000000">                </span><span style="color: #0000ff">return</span><span style="color: #000000"> defaultValue;<br />             </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="color: #0000ff">if</span><span style="color: #000000"> (raw </span><span style="color: #0000ff">is</span><span style="color: #000000"> T) </span><span style="color: #008000">//</span><span style="color: #008000">成功</span><span style="color: #008000"><br /> </span><span style="color: #000000">            {<br />                 convertSuccessful </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">true</span><span style="color: #000000">;<br />                 </span><span style="color: #0000ff">return</span><span style="color: #000000"> (T)raw;<br />             }<br />             </span><span style="color: #0000ff">else</span><span style="color: #000000"><br />             {<br />                 </span><span style="color: #0000ff">try</span><span style="color: #000000"><br />                 {<br />                     </span><span style="color: #0000ff">object</span><span style="color: #000000">[] parms </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> </span><span style="color: #0000ff">object</span><span style="color: #000000">[</span><span style="color: #000000">2</span><span style="color: #000000">];<br />                     parms[</span><span style="color: #000000">0</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> raw.ToString();<br />                     parms[</span><span style="color: #000000">1</span><span style="color: #000000">] </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br />                     </span><span style="color: #0000ff">bool</span><span style="color: #000000"> isparser </span><span style="color: #000000">=</span><span style="color: #000000"> (</span><span style="color: #0000ff">bool</span><span style="color: #000000">)prepareMethod(</span><span style="color: #0000ff">typeof</span><span style="color: #000000">(T)).Invoke(</span><span style="color: #0000ff">null</span><span style="color: #000000">, parms);<br />                     </span><span style="color: #0000ff">if</span><span style="color: #000000"> (isparser) </span><span style="color: #008000">//</span><span style="color: #008000">成功</span><span style="color: #008000"><br /> </span><span style="color: #000000">                    {<br />                         convertSuccessful </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">true</span><span style="color: #000000">;<br />                         </span><span style="color: #0000ff">return</span><span style="color: #000000"> (T)parms[</span><span style="color: #000000">1</span><span style="color: #000000">];<br />                     }<br />                 }<br />                 </span><span style="color: #0000ff">catch</span><span style="color: #000000"><br />                 {<br />                 }<br />                 </span><span style="color: #0000ff">return</span><span style="color: #000000"> defaultValue;<br />             }<br />         } </span><span style="color: #008000">//</span><span style="color: #008000">end Convert<T></span><span style="color: #008000"><br /> </span><span style="color: #000000">    }<br /> }<br /> </span></div> <br /> 以上代码的写法,适合DateTime,Int32,Int64,Int16,byte,bool{。只有是structl构Qƈ且有TryParseҎ(gu)可以用。而用v来呢也很单,如以下代?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: #0000ff">namespace</span><span style="color: #000000"> DObject.DType<br /> {<br />     </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />     </span><span style="color: #808080">///</span><span style="color: #008000"> Int32cd保证<br />     </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #808080"><br /> </span><span style="color: #000000">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> DInt32 : DObject, IValuetable</span><span style="color: #000000"><</span><span style="color: #000000">Int32</span><span style="color: #000000">></span><span style="color: #000000">, IConvertSuccess<br />     {<br />         </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> target;<br />         </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> defaultValue </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">;<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> 构造函敎ͼ对象初始化时Q就执行转换<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><param name="o"></param></span><span style="color: #808080"><br /> </span><span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> DInt32(</span><span style="color: #0000ff">object</span><span style="color: #000000"> o)<br />             : </span><span style="color: #0000ff">base</span><span style="color: #000000">(o)<br />         {<br />             target </span><span style="color: #000000">=</span><span style="color: #000000"> StaticConvertor.Convert</span><span style="color: #000000"><</span><span style="color: #0000ff">int</span><span style="color: #000000">></span><span style="color: #000000">(</span><span style="color: #0000ff">base</span><span style="color: #000000">.raw, defaultValue, </span><span style="color: #0000ff">out</span><span style="color: #000000"> convertSuccessful);<br />         }<br /> <br />         </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">implicit</span><span style="color: #000000"> </span><span style="color: #0000ff">operator</span><span style="color: #000000"> DInt32(DType type)<br />         {<br />             </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> DInt32(type.RawObject);<br />         }<br /> <br />         </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">bool</span><span style="color: #000000"> convertSuccessful;<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> q回转换?br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><returns></span><span style="color: #008000">q回转换|如果转换成功则返回|转换p|q回默认?nbsp;-1</span><span style="color: #808080"></returns></span><span style="color: #808080"><br /> </span><span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> Value()<br />         {<br />             </span><span style="color: #0000ff">return</span><span style="color: #000000"> Value(defaultValue);<br />         }<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> q回转换?br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><param name="defaultValue"></span><span style="color: #008000">默认?/span><span style="color: #808080"></param></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><returns></span><span style="color: #008000">q回转换|如果转换成功则返回|转换p|q回默认?/span><span style="color: #808080"></returns></span><span style="color: #808080"><br /> </span><span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> Value(</span><span style="color: #0000ff">int</span><span style="color: #000000"> defaultValue)<br />         {<br />             </span><span style="color: #0000ff">if</span><span style="color: #000000"> (convertSuccessful)<br />                 </span><span style="color: #0000ff">return</span><span style="color: #000000"> target;<br />             </span><span style="color: #0000ff">return</span><span style="color: #000000"> defaultValue;<br />         }<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> 是否转换成功<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #808080"><br /> </span><span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">bool</span><span style="color: #000000"> ConvertSuccess<br />         {<br />             </span><span style="color: #0000ff">get</span><span style="color: #000000"> { </span><span style="color: #0000ff">return</span><span style="color: #000000"> convertSuccessful; }<br />         }<br />     }<br /> }<br /> </span></div> <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: #000000">    </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />     </span><span style="color: #808080">///</span><span style="color: #008000"> 构造类型,为内|类型提供构造参数?br />     </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><example></span><span style="color: #008000"><br />     </span><span style="color: #808080">///</span><span style="color: #008000">        DInt32 int32 = DType.Default("123");<br />     </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></example></span><span style="color: #008000"><br />     </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #808080"><br /> </span><span style="color: #000000">    </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> DType<br />     {<br />         </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">object</span><span style="color: #000000"> o;<br /> <br />         </span><span style="color: #0000ff">private</span><span style="color: #000000"> DType(</span><span style="color: #0000ff">object</span><span style="color: #000000"> o)<br />         {<br />             </span><span style="color: #0000ff">this</span><span style="color: #000000">.o </span><span style="color: #000000">=</span><span style="color: #000000"> o;<br />         }<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> 提供对象构造参?br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><param name="o"></param></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><returns></returns></span><span style="color: #808080"><br /> </span><span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> DType Default(</span><span style="color: #0000ff">object</span><span style="color: #000000"> o)<br />         {<br />             </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> DType(o);<br />         }<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"><summary></span><span style="color: #008000"><br />         </span><span style="color: #808080">///</span><span style="color: #008000"> 原始对象<br />         </span><span style="color: #808080">///</span><span style="color: #008000"> </span><span style="color: #808080"></summary></span><span style="color: #808080"><br /> </span><span style="color: #000000">        </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">object</span><span style="color: #000000"> RawObject<br />         {<br />             </span><span style="color: #0000ff">get</span><span style="color: #000000"> { </span><span style="color: #0000ff">return</span><span style="color: #000000"> o; }<br />         }<br />     }</span></div> <br /> 使用h也是单:<br /> DInt32 int32 = DType.Default("123");<br /> int val = int32.Value();<br /> <br /> Java里就没这L了,使用try捕获错误q惌的。java里没有structQ但是有个类型Number是可以使用。当Ӟq就不能像C#一样将׃八糟的东襉K整一块了Q要分开来处理了?br /> <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: #008000">/**</span><span style="color: #008000"><br />  *<br />  * </span><span style="color: #808080">@author</span><span style="color: #008000"> yurow<br />  </span><span style="color: #008000">*/</span><span style="color: #000000"><br /> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> DNumber </span><span style="color: #0000ff">extends</span><span style="color: #000000"> DObject {<br /> <br />     </span><span style="color: #008000">/**</span><span style="color: #008000"><br />      * Create new instance of DNumber<br />      </span><span style="color: #008000">*/</span><span style="color: #000000"><br />     </span><span style="color: #0000ff">protected</span><span style="color: #000000"> DNumber() {<br />         </span><span style="color: #0000ff">super</span><span style="color: #000000">();<br />     }<br /> <br />     </span><span style="color: #0000ff">protected</span><span style="color: #000000"> DNumber(Object obj)<br />     {<br />         </span><span style="color: #0000ff">super</span><span style="color: #000000">(obj);<br />     }<br />     <br />     </span><span style="color: #0000ff">protected</span><span style="color: #000000"> Boolean isconvert;<br /> <br />     </span><span style="color: #0000ff">public</span><span style="color: #000000"> Number Convert(Number defaultValue) {<br />         isconvert </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">false</span><span style="color: #000000">;<br />         </span><span style="color: #0000ff">if</span><span style="color: #000000"> (obj </span><span style="color: #000000">==</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">) {<br />             </span><span style="color: #0000ff">return</span><span style="color: #000000"> defaultValue;<br />         } </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="color: #0000ff">if</span><span style="color: #000000"> (obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Number) {<br />             isconvert </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">true</span><span style="color: #000000">;<br />             </span><span style="color: #0000ff">return</span><span style="color: #000000"> Number.</span><span style="color: #0000ff">class</span><span style="color: #000000">.cast(obj);<br />         } </span><span style="color: #0000ff">else</span><span style="color: #000000"> {<br />             </span><span style="color: #0000ff">return</span><span style="color: #000000"> defaultValue;<br />         }<br />     }<br /> }<br /> </span></div> <br /> <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: #008000">/**</span><span style="color: #008000"><br />  *<br />  * </span><span style="color: #808080">@author</span><span style="color: #008000"> yurow<br />  </span><span style="color: #008000">*/</span><span style="color: #000000"><br /> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> DInt32 </span><span style="color: #0000ff">extends</span><span style="color: #000000"> DNumber {<br /> <br />     </span><span style="color: #008000">/**</span><span style="color: #008000"><br />      * Create new instance of DInt32<br />      </span><span style="color: #008000">*/</span><span style="color: #000000"><br />     </span><span style="color: #0000ff">protected</span><span style="color: #000000"> DInt32() {<br />         </span><span style="color: #0000ff">super</span><span style="color: #000000">();<br />     }<br /> <br />     </span><span style="color: #0000ff">protected</span><span style="color: #000000"> DInt32(Object obj) {<br />         </span><span style="color: #0000ff">super</span><span style="color: #000000">(obj);<br />     }<br /> <br />     </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> DInt32 newInt32(Object obj) {<br />         </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> DInt32(obj);<br />     }<br /> <br />     </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> Convert()<br />     {<br />         </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #0000ff">super</span><span style="color: #000000">.Convert(</span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">).intValue();<br />     }<br /> }<br /> </span></div> <br /> 可以看出QJAVA的类型逻辑层次划分比C#要细_处理h当然要复杂一些。可见粒度ƈ非越l越好。道看来JAVA們֐于按逻辑划分Q而C#們֐于按内存布局划分? <img src ="http://www.aygfsteel.com/birdshover/aggbug/245255.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/birdshover/" target="_blank">Birdshover</a> 2008-12-09 15:18 <a href="http://www.aygfsteel.com/birdshover/archive/2008/12/09/245255.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>反射字段获取所有字D输?/title><link>http://www.aygfsteel.com/birdshover/archive/2008/12/08/245069.html</link><dc:creator>Birdshover</dc:creator><author>Birdshover</author><pubDate>Mon, 08 Dec 2008 09:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/birdshover/archive/2008/12/08/245069.html</guid><wfw:comment>http://www.aygfsteel.com/birdshover/comments/245069.html</wfw:comment><comments>http://www.aygfsteel.com/birdshover/archive/2008/12/08/245069.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/birdshover/comments/commentRss/245069.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/birdshover/services/trackbacks/245069.html</trackback:ping><description><![CDATA[<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: rgb(0, 0, 0);">    @Override<br />     </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> String toString() {<br />         StringBuffer buffer </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> StringBuffer();<br />         </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">q回所有字D?/span><span style="color: rgb(0, 128, 0);"><br /> </span><span style="color: rgb(0, 0, 0);">        Field[] fields </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.getClass().getDeclaredFields();<br />         </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">; i </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);"> fields.length; i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">) {<br />             </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">当前字段名称</span><span style="color: rgb(0, 128, 0);"><br /> </span><span style="color: rgb(0, 0, 0);">            String name </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> fields[i].getName();<br />             buffer.append(name);<br />             buffer.append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />             </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);"> {<br />                 </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">当前实例该字D?/span><span style="color: rgb(0, 128, 0);"><br /> </span><span style="color: rgb(0, 0, 0);">                buffer.append(fields[i].get(</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">));<br />             } </span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);"> (Exception ex) {<br />                 System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">err:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> ex.getMessage());<br />             }<br />             buffer.append(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\n</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />         }<br />         </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> buffer.toString();<br />     }</span></div> <img src ="http://www.aygfsteel.com/birdshover/aggbug/245069.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/birdshover/" target="_blank">Birdshover</a> 2008-12-08 17:55 <a href="http://www.aygfsteel.com/birdshover/archive/2008/12/08/245069.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse System.in对中文输入法支持不够?/title><link>http://www.aygfsteel.com/birdshover/archive/2008/12/05/244601.html</link><dc:creator>Birdshover</dc:creator><author>Birdshover</author><pubDate>Fri, 05 Dec 2008 06:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/birdshover/archive/2008/12/05/244601.html</guid><wfw:comment>http://www.aygfsteel.com/birdshover/comments/244601.html</wfw:comment><comments>http://www.aygfsteel.com/birdshover/archive/2008/12/05/244601.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/birdshover/comments/commentRss/244601.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/birdshover/services/trackbacks/244601.html</trackback:ping><description><![CDATA[<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 id="Codehighlighter1_23_216_Open_Image" onclick="this.style.display='none'; Codehighlighter1_23_216_Open_Text.style.display='none'; Codehighlighter1_23_216_Closed_Image.style.display='inline'; Codehighlighter1_23_216_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_23_216_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_23_216_Closed_Text.style.display='none'; Codehighlighter1_23_216_Open_Image.style.display='inline'; Codehighlighter1_23_216_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" /><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> testclass </span><span id="Codehighlighter1_23_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" alt="" /></span><span id="Codehighlighter1_23_216_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </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 style="color: #0000ff">throws</span><span style="color: #000000"> IOException<br /> <img id="Codehighlighter1_85_214_Open_Image" onclick="this.style.display='none'; Codehighlighter1_85_214_Open_Text.style.display='none'; Codehighlighter1_85_214_Closed_Image.style.display='inline'; Codehighlighter1_85_214_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_85_214_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_85_214_Closed_Text.style.display='none'; Codehighlighter1_85_214_Open_Image.style.display='inline'; Codehighlighter1_85_214_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" alt="" />    </span><span id="Codehighlighter1_85_214_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" alt="" /></span><span id="Codehighlighter1_85_214_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">byte</span><span style="color: #000000">[] buffer </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> </span><span style="color: #0000ff">byte</span><span style="color: #000000">[</span><span style="color: #000000">1024</span><span style="color: #000000">];<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">int</span><span style="color: #000000"> count </span><span style="color: #000000">=</span><span style="color: #000000"> System.in.read(buffer);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />        System.out.print(</span><span style="color: #0000ff">new</span><span style="color: #000000"> String(buffer,</span><span style="color: #000000">0</span><span style="color: #000000">,count,</span><span style="color: #000000">"</span><span style="color: #000000">gbk</span><span style="color: #000000">"</span><span style="color: #000000">));<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span></div> <br /> q样一D代码,在输入中文时Q如果输?#8220;ces”然后敲空|得到“试”q两个字QenterQ然后输?br /> “ces试”?br /> <br /> 要是用Consoleq行Qjava testclass 则没有这U问? <img src ="http://www.aygfsteel.com/birdshover/aggbug/244601.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/birdshover/" target="_blank">Birdshover</a> 2008-12-05 14:55 <a href="http://www.aygfsteel.com/birdshover/archive/2008/12/05/244601.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hibernate ,Serverlet POST查询http://www.aygfsteel.com/birdshover/archive/2008/11/26/242888.htmlBirdshoverBirdshoverWed, 26 Nov 2008 14:18:00 GMThttp://www.aygfsteel.com/birdshover/archive/2008/11/26/242888.htmlhttp://www.aygfsteel.com/birdshover/comments/242888.htmlhttp://www.aygfsteel.com/birdshover/archive/2008/11/26/242888.html#Feedback0http://www.aygfsteel.com/birdshover/comments/commentRss/242888.htmlhttp://www.aygfsteel.com/birdshover/services/trackbacks/242888.html        try {
            String username 
= request.getParameter("username");
            String password 
= request.getParameter("password");
            SessionFactory sf 
= DefaultDataUtil.getSessionFactory();
            Session s 
= sf.openSession();
            Query query 
= s.createQuery("from Users where username=:name");
            query.setParameter(
"name", username);
            List list 
= query.list();
            
if(list.size() == 1)
            {
                Object o 
= list.get(0);
                Users user 
= (Users)o;
                
if(user.getPassword().equals(password) )
                {
                    out.print(
"验证成功?/span>");
                }
                
else
                {
                    out.print(
"密码错误?/span>");
                }
            }
            
else
            {
                out.print(
"用户名错误?/span>");
            }
        }
        
catch(Exception ex){
            out.print(ex.getMessage());
        }
        
finally {
            out.close();
        }

HQL语句对于表名有大写匚w的关p,匚w的映过来的cd。否则会报xxx not mapped....错误。其它的q是很简单的?

Birdshover 2008-11-26 22:18 发表评论
]]>
վ֩ģ壺 | | ˮ| | ˳ƽ| | ΢ɽ| пѷ| | | Ϫ| ͭ| ʲ| | | ɽ| մ| | | ɽ| Ǹ| | Ͼ| | ʹ| ̨| ݶ| Դ| | | | ˮ| | | | Ƹ| Ʊ| | | ̳| |