锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品亚洲综合一区在线观看,色欲色欲天天天www亚洲伊,日韩精品亚洲aⅴ在线影院http://www.tkk7.com/niuniu/category/37488.htmlzh-cnTue, 10 Feb 2009 06:27:56 GMTTue, 10 Feb 2009 06:27:56 GMT60Tomcat5.5鏁版嵁婧愰厤緗?/title><link>http://www.tkk7.com/niuniu/archive/2009/02/05/JDBCDataSources.html</link><dc:creator>鐗?-鐗?/dc:creator><author>鐗?-鐗?/author><pubDate>Thu, 05 Feb 2009 14:04:00 GMT</pubDate><guid>http://www.tkk7.com/niuniu/archive/2009/02/05/JDBCDataSources.html</guid><wfw:comment>http://www.tkk7.com/niuniu/comments/253455.html</wfw:comment><comments>http://www.tkk7.com/niuniu/archive/2009/02/05/JDBCDataSources.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/niuniu/comments/commentRss/253455.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/niuniu/services/trackbacks/253455.html</trackback:ping><description><![CDATA[<p>    寮鍙戠幆澧?<br />           MyEclipse5.5<br />           Tomcat5.5<br />           MsSql2000</p>     鏁版嵁婧愰厤緗茍涓嶉毦,鐩稿鏉ヨ姣旇緝楹葷儲,鍒悡鐫浜?鍏跺疄灝辨槸澶氫釜鍦版柟鎷瘋礉.<br /> <br />    鍦═omcat瀹夎鐩綍鎵懼埌conf鏂囦歡澶逛笅鐨剆erver.xml.鎵撳紑鍦℉ost鑺傜偣涓嬬紪杈? <div style="padding-right: 5px; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left-color: #cccccc; width: 98%; word-break: break-all; padding-top: 4px; background-color: #eeeeee; "><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff"><</span><span style="color: #800000">Resource <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jdbc/emp"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />auth</span><span style="color: #0000ff">="Container"</span><span style="color: #ff0000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />type</span><span style="color: #0000ff">="javax.sql.DataSource"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />username</span><span style="color: #0000ff">="sa"</span><span style="color: #ff0000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />password</span><span style="color: #0000ff">="sa"</span><span style="color: #ff0000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />driverClassName</span><span style="color: #0000ff">="com.microsoft.jdbc.sqlserver.SQLServerDriver"</span><span style="color: #ff0000">    url</span><span style="color: #0000ff">="jdbc:microsoft:sqlserver://localhost;DatabaseName=pubs"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />maxActive</span><span style="color: #0000ff">="8"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />maxIdle</span><span style="color: #0000ff">="4"</span><span style="color: #ff0000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">/></span></div> name:灞炴у煎彲闅忔剰鍙栧?浣嗕笉鍏佽涓虹┖.<br /> 闄uth灞炴у煎浐瀹氬叾瀹冮兘闅忛渶姹傝屽彉.<br /> 渚嬪:username鐨勫?闅忎綘鏁版嵁搴撶櫥褰曞悕鑰屽彉鍔?<br /> 鎺ヤ笅鏉?鎴戜滑闇瑕佸湪Tomcat 5.5\conf\Catalina\localhost璺緞涓嬫柊寤轟竴涓拰宸ョ▼鍚嶅悓鏍風殑xml鏂囦歡.<br /> 鍋囪浣犳柊寤虹殑Web宸ョ▼鍚嶅彨JdbcDataSource,鍒橨dbcDataSource.xml.<br /> <div style="padding-right: 5px; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left-color: #cccccc; width: 98%; word-break: break-all; padding-top: 4px; background-color: #eeeeee; "><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff"><?</span><span style="color: #ff00ff">xml version="1.0" encoding="UTF-8"</span><span style="color: #0000ff">?></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff"><</span><span style="color: #800000">Context</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff"><</span><span style="color: #800000">Resource <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jdbc/emp"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />auth</span><span style="color: #0000ff">="Container"</span><span style="color: #ff0000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />type</span><span style="color: #0000ff">="javax.sql.DataSource"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />username</span><span style="color: #0000ff">="sa"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />password</span><span style="color: #0000ff">="sa"</span><span style="color: #ff0000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />driverClassName</span><span style="color: #0000ff">="com.microsoft.jdbc.sqlserver.SQLServerDriver"</span><span style="color: #ff0000">   url</span><span style="color: #0000ff">="jdbc:microsoft:sqlserver://localhost;DatabaseName=pubs"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />maxActive</span><span style="color: #0000ff">="8"</span><span style="color: #ff0000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />maxIdle</span><span style="color: #0000ff">="4"</span><span style="color: #ff0000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span></div> 鐪嬫竻妤氫簡鍚?鍏跺疄灝辨槸鎶婁綘鍦╯erver.xml杈撳叆鐨勬嫹璐濊繃鏉ュ氨鏄簡.<br /> 濂戒簡,鎴戜滑鐜板湪鍒囨崲鍒癐DE,鍦ㄥ綋鍓嶇殑宸ョ▼web.xml涓嬪啀榪涜涓嬈¢厤緗?<br /> <div style="padding-right: 5px; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left-color: #cccccc; width: 98%; word-break: break-all; padding-top: 4px; background-color: #eeeeee; "><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="color: #0000ff"><</span><span style="color: #800000">resource-ref</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span><span style="color: #0000ff"><</span><span style="color: #800000">res-ref-name</span><span style="color: #0000ff">></span><span style="color: #000000">jdbc/emp</span><span style="color: #0000ff"></</span><span style="color: #800000">res-ref-name</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span><span style="color: #0000ff"><</span><span style="color: #800000">res-type</span><span style="color: #0000ff">></span><span style="color: #000000">javax.sql.DataSource</span><span style="color: #0000ff"></</span><span style="color: #800000">res-type</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span><span style="color: #0000ff"><</span><span style="color: #800000">res-auth</span><span style="color: #0000ff">></span><span style="color: #000000">Container</span><span style="color: #0000ff"></</span><span style="color: #800000">res-auth</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img alt="" src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="color: #0000ff"></</span><span style="color: #800000">resource-ref</span><span style="color: #0000ff">></span><span style="color: #000000">    </span></div> 涓鍒囬厤緗甇k,鎺ヤ笅鏉ユ垜浠潵嫻嬭瘯鏄惁鍙.<br /> <div style="padding-right: 5px; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left-color: #cccccc; width: 98%; word-break: break-all; padding-top: 4px; background-color: #eeeeee; "><span style="color: #008080"> 1</span><img id="Codehighlighter1_0_59_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_59_Open_Text.style.display='none'; Codehighlighter1_0_59_Closed_Image.style.display='inline'; Codehighlighter1_0_59_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_0_59_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_0_59_Closed_Text.style.display='none'; Codehighlighter1_0_59_Open_Image.style.display='inline'; Codehighlighter1_0_59_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /><span id="Codehighlighter1_0_59_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_59_Open_Text"><span style="color: #008000">/**</span><span style="color: #008000"><br /> </span><span style="color: #008080"> 2</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> * Tomcat5.5榪炴帴姹犻厤緗?br /> </span><span style="color: #008080"> 3</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> * 鏁版嵁搴撲負Ms2000<br /> </span><span style="color: #008080"> 4</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> * </span><span style="color: #808080">@author</span><span style="color: #008000"> NiuNiu<br /> </span><span style="color: #008080"> 5</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> *<br /> </span><span style="color: #008080"> 6</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /> </span><span style="color: #008080"> 7</span><span style="color: #000000"><img id="Codehighlighter1_89_629_Open_Image" onclick="this.style.display='none'; Codehighlighter1_89_629_Open_Text.style.display='none'; Codehighlighter1_89_629_Closed_Image.style.display='inline'; Codehighlighter1_89_629_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /><img id="Codehighlighter1_89_629_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_89_629_Closed_Text.style.display='none'; Codehighlighter1_89_629_Open_Image.style.display='inline'; Codehighlighter1_89_629_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.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"> Tomcat5_5_Pool </span><span id="Codehighlighter1_89_629_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.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_89_629_Open_Text"><span style="color: #000000">{    <br /> </span><span style="color: #008080"> 8</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.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"> Connection getConnection()<br /> </span><span style="color: #008080"> 9</span><span style="color: #000000"><img id="Codehighlighter1_135_627_Open_Image" onclick="this.style.display='none'; Codehighlighter1_135_627_Open_Text.style.display='none'; Codehighlighter1_135_627_Closed_Image.style.display='inline'; Codehighlighter1_135_627_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_135_627_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_135_627_Closed_Text.style.display='none'; Codehighlighter1_135_627_Open_Image.style.display='inline'; Codehighlighter1_135_627_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span><span id="Codehighlighter1_135_627_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.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_135_627_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">10</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        Connection con</span><span style="color: #000000">=</span><span style="color: #0000ff">null</span><span style="color: #000000">;        <br /> </span><span style="color: #008080">11</span><span style="color: #000000"><img id="Codehighlighter1_168_516_Open_Image" onclick="this.style.display='none'; Codehighlighter1_168_516_Open_Text.style.display='none'; Codehighlighter1_168_516_Closed_Image.style.display='inline'; Codehighlighter1_168_516_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_168_516_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_168_516_Closed_Text.style.display='none'; Codehighlighter1_168_516_Open_Image.style.display='inline'; Codehighlighter1_168_516_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span><span style="color: #0000ff">try</span><span style="color: #000000"> </span><span id="Codehighlighter1_168_516_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.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_168_516_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">12</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="color: #008000">//</span><span style="color: #008000">鍒濆鍖栨煡鎵?/span><span style="color: #008000"><br /> </span><span style="color: #008080">13</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #000000">            Context initCtx </span><span style="color: #000000">=</span><span style="color: #0000ff">new</span><span style="color: #000000"> InitialContext();<br /> </span><span style="color: #008080">14</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="color: #008000">//</span><span style="color: #008000">寰楀埌dataSource</span><span style="color: #008000"><br /> </span><span style="color: #008080">15</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #000000">            Context envCtx </span><span style="color: #000000">=</span><span style="color: #000000">(Context)initCtx.lookup(</span><span style="color: #000000">"</span><span style="color: #000000">java:comp/env</span><span style="color: #000000">"</span><span style="color: #000000">);<br /> </span><span style="color: #008080">16</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />            DataSource dataSource</span><span style="color: #000000">=</span><span style="color: #000000">(DataSource)envCtx.lookup(</span><span style="color: #000000">"</span><span style="color: #000000">jdbc/emp</span><span style="color: #000000">"</span><span style="color: #000000">);    <br /> </span><span style="color: #008080">17</span><span style="color: #000000"><img id="Codehighlighter1_377_418_Open_Image" onclick="this.style.display='none'; Codehighlighter1_377_418_Open_Text.style.display='none'; Codehighlighter1_377_418_Closed_Image.style.display='inline'; Codehighlighter1_377_418_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_377_418_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_377_418_Closed_Text.style.display='none'; Codehighlighter1_377_418_Open_Image.style.display='inline'; Codehighlighter1_377_418_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            </span><span style="color: #0000ff">try</span><span style="color: #000000"> </span><span id="Codehighlighter1_377_418_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.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_377_418_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">18</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />                con</span><span style="color: #000000">=</span><span style="color: #000000">dataSource.getConnection();<br /> </span><span style="color: #008080">19</span><span style="color: #000000"><img id="Codehighlighter1_443_512_Open_Image" onclick="this.style.display='none'; Codehighlighter1_443_512_Open_Text.style.display='none'; Codehighlighter1_443_512_Closed_Image.style.display='inline'; Codehighlighter1_443_512_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_443_512_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_443_512_Closed_Text.style.display='none'; Codehighlighter1_443_512_Open_Image.style.display='inline'; Codehighlighter1_443_512_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />            }</span></span><span style="color: #000000"> </span><span style="color: #0000ff">catch</span><span style="color: #000000"> (SQLException e) </span><span id="Codehighlighter1_443_512_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.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_443_512_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">20</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />                </span><span style="color: #008000">//</span><span style="color: #008000"> TODO Auto-generated catch block</span><span style="color: #008000"><br /> </span><span style="color: #008080">21</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #000000">                e.printStackTrace();<br /> </span><span style="color: #008080">22</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />            }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">23</span><span style="color: #000000"><img id="Codehighlighter1_544_610_Open_Image" onclick="this.style.display='none'; Codehighlighter1_544_610_Open_Text.style.display='none'; Codehighlighter1_544_610_Closed_Image.style.display='inline'; Codehighlighter1_544_610_Closed_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_544_610_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_544_610_Closed_Text.style.display='none'; Codehighlighter1_544_610_Open_Image.style.display='inline'; Codehighlighter1_544_610_Open_Text.style.display='inline';" alt="" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        }</span></span><span style="color: #000000"> </span><span style="color: #0000ff">catch</span><span style="color: #000000"> (NamingException e) </span><span id="Codehighlighter1_544_610_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.tkk7.com/Images/dot.gif" /></span><span id="Codehighlighter1_544_610_Open_Text"><span style="color: #000000">{<br /> </span><span style="color: #008080">24</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />            </span><span style="color: #008000">//</span><span style="color: #008000"> TODO Auto-generated catch block</span><span style="color: #008000"><br /> </span><span style="color: #008080">25</span><span style="color: #008000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /></span><span style="color: #000000">            e.printStackTrace();<br /> </span><span style="color: #008080">26</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">27</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> con;<br /> </span><span style="color: #008080">28</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span></span><span style="color: #000000"><br /> </span><span style="color: #008080">29</span><span style="color: #000000"><img alt="" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span></span></div> 濡傛灉getConnection()鏂規硶榪斿洖闈炵┖,灝辮〃紺烘垜浠笂榪板仛鐨勬搷浣滈兘姝g‘浜?<br /> <br /> 娉ㄦ剰:<br />         鎴戜滑闇瑕佹妸DB椹卞姩鍖呬篃瑕佹嫹璐濆埌Tomcat 5.5\common\lib鐩綍涓?<br />         Context envCtx =(Context)initCtx.lookup("java:comp/env");<br />         DataSource dataSource=(DataSource)envCtx.lookup("jdbc/emp"); <br />         java:comp/env鏄浐瀹氱殑,浣嗗湪WebLogic鏈嶅姟鍣ㄥ垯鍙互涓嶉渶瑕佸啓涓?<br />         jdbc/emp灝辨槸浣犳墍娉ㄥ唽鐨勫悕鍟?<br /> 鍙傝冭祫鏂?<a >http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html</a> <img src ="http://www.tkk7.com/niuniu/aggbug/253455.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/niuniu/" target="_blank">鐗?-鐗?/a> 2009-02-05 22:04 <a href="http://www.tkk7.com/niuniu/archive/2009/02/05/JDBCDataSources.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Struts2鍒濇帰http://www.tkk7.com/niuniu/archive/2009/02/04/253326.html鐗?-鐗?/dc:creator>鐗?-鐗?/author>Wed, 04 Feb 2009 15:20:00 GMThttp://www.tkk7.com/niuniu/archive/2009/02/04/253326.htmlhttp://www.tkk7.com/niuniu/comments/253326.htmlhttp://www.tkk7.com/niuniu/archive/2009/02/04/253326.html#Feedback0http://www.tkk7.com/niuniu/comments/commentRss/253326.htmlhttp://www.tkk7.com/niuniu/services/trackbacks/253326.html 渚嬪Struts,鐜板湪瀹冨凡緇?鍗?綰у埌Struts2,瀹冨茍涓嶆槸涓涓増鏈殑寤跺崌,鑰屾槸鐢盨truts鍜學ebWork鐨勭粨鍚?鍚稿彇浜嗕袱鑰呯殑綺懼崕,浠庤屽悎浜屼負涓,鍥犳璇炵敓浜?..涔嬪彇鍚嶄負Struts2.
涓轟簡闇瑕?涔熷紑濮嬩簡瀛︿範Struts涔嬫梾.

Struts2鍒濇帰
瀹炵幇鈥?[綆鎹烽棶鍊欒]
鍏靛櫒:
MyEclipse5.5
Tomcat5.5
Jdk1.5
涓昏:
Struts2
鐐瑰嚮涔嬪涓嬭澆Struts2
瑁呭鍑嗗鍏跺叏,Go Go Go
1.棣栧厛鏂板緩涓涓猈eb宸ョ▼,絀哄3澹沖涓?

2.浣跨敤Struts2,鎴戜滑闇瑕佽寮曠敤瀹冪殑鍖?涓鑸儏鍐典笅鎴戜滑鍙渶瑕佷簲涓寘灝辮凍澶熶簡.
浜斾釜鍖呭垎鍒槸:
commons-logging-1.0.4.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.11.1.jar
xwork-2.0.4.jar
鎶婅繖浜斾釜鍖呭鍒跺埌宸ョ▼lib鐩綍涓?鐒跺悗鍦╯rc鐩綍涓嬫柊寤轟竴涓悕涓簊truts.xml鐨剎ml鏂囦歡.
瑕佹兂Struts2璧峰埌浣滅敤,榪涜宸ヤ綔鎴戜滑闇瑕佸湪web.xml閰嶇疆鏂囦歡,澧炲姞Struts2鐨勬牳蹇僃ilter.
<!-- 閰嶇疆Struts2鏍稿績榪囨護鍣?-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<!-- Struts2 Mapping -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
鎻愮ず:濡傛灉蹇樿Struts2鏍稿績Filter璺緞鍙互鍦╯truts2-core-2.0.11.1.jar涓嬫壘鍒?

鑷蟲鍐嶅湪宸ョ▼寤虹珛涓涓寘,騫跺湪璇ュ寘寤虹珛涓涓帶鍒跺櫒綾?鎺у埗鍣ㄩ潪甯哥畝鍗?灝卞涓涓櫘閫氱殑PoJo綾?(Struts2.java)
1package com.company.struts.demo.action;
2
3import javax.servlet.http.HttpServletRequest;
4import org.apache.struts2.ServletActionContext;
5
6/**
7 * Struts2鍒濇帰
8 *
9 * @author NiuNiu
10 *
11 */

12public class Struts2 {
13
14 String hi;
15
16 // 澶勭悊鐢ㄦ埛璇鋒眰鏂規硶
17 // 褰揳ction鏈寚瀹歮ethod灞炴ф椂 榛樿鎸囧悜execute鏂規硶
18 public String execute() {
19
20 HttpServletRequest request = ServletActionContext.getRequest();
21
22 request.setAttribute("hi", getHi());
23
24 return "success";
25 }

26
27 /**
28 * get / set
29 *
30 */

31
32 public String getHi() {
33 return hi;
34 }

35
36 public void setHi(String hi) {
37 this.hi = hi;
38 }

39}

榪樿寰梥truts.xml涔堬紵 鍛靛懙
涓婅堪涓鍒囬兘ok,榪樹笉鑳藉鐞嗙敤鎴風殑璇鋒眰,涓烘灝辨槸struts.xml鍙戞尌浣滅敤鐨勬椂鍊欏埌浜?
1<!DOCTYPE struts PUBLIC
2 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
3 "http://struts.apache.org/dtds/struts-2.0.dtd">
4<struts>
5 <package name="struts2" extends="struts-default">
6 <!--
7 name:鎻愪氦鏃墮渶瑕佹寚鍚慉ction鐨勫埆鍚?br /> 8 class:鎸囧畾Action璺緞
9 -->
10 <action name="struts" class="com.company.struts.demo.action.Struts2">
11 <!-- 璧勬簮鏄犲皠 -->
12 <result name="success">/success.jsp</result>
13 </action>
14 </package>
15</struts>
鎻愮ず:dtd鎴戞槸鎳掑緱鍘昏鐨?鍛婅瘔浣犱竴涓姙娉?鍦╯truts2-core-2.0.11.1.jar涓嬬殑struts-2.0.dtd涓嬪彲鎵懼埌.
綆鎹風殑闂欒? 鍝?榪橀渶瑕佷竴涓〉闈㈣瀹冩潵浼犻掍俊鎭?chutanstruts2.jsp).
1<%@ page language="java" pageEncoding="utf-8"%>
2<!-- 寮曞叆Struts2鏍囩 -->
3<%@ taglib prefix="s" uri="/struts-tags" %>
4<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5<html>
6 <head>
7 <title>Struts2鍒濇帰</title>
8 </head>
9 <body>
10 <!-- 榪欓噷鐨剆truts灝辨槸鍦╯truts.xml閰嶇疆Action鐨勫埆鍚?-->
11 <s:form action="struts">
12 <s:textfield name="hi" label="Say"></s:textfield>
13 <s:submit value="Go"></s:submit>
14 </s:form>
15 </body>
16</html>
緇撴灉欏?success.jsp):
1<%@ page language="java" isELIgnored="false" pageEncoding="utf-8"%>
2<%@ taglib prefix="s" uri="/struts-tags" %>
3<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4<html>
5 <head>
6 <title>success</title>
7 </head>
8 <body>
9 Hi <font color=red><s:property value="hi"/></font>
10 <br/>
11 I like ${hi}
12 </body>
13</html>
浠ヤ笅灝辨槸欏圭洰緇撴瀯鏈緇堝浘:

鍐嶇湅鏈緇堟墍瑕佸憟鐜扮殑緇撴灉:


---------------------------------鍒嗗壊綰?---------------------------
娉?/strong>:
struts.xml蹇呴』鏀懼湪src鏍圭洰褰曚笅
struts.xml蹇呴』鍏ㄩ兘鏄皬鍐?騫朵笖鏂囦歡鍚嶄篃蹇呴』鏄痵truts.xml.


]]>
主站蜘蛛池模板: 嫩草在线视频www免费看| 亚洲综合一区二区精品久久| 亚洲第一第二第三第四第五第六| 7723日本高清完整版免费| 亚洲自偷自拍另类12p| 未满十八18禁止免费无码网站| 亚洲AV永久无码精品一百度影院| 99视频免费在线观看| 久久精品国产亚洲AV高清热| 9420免费高清在线视频| 亚洲手机中文字幕| 日韩在线视频免费看| 污网站在线观看免费| 国产亚洲精品一品区99热| 日本人成在线视频免费播放| 亚洲国产成人精品无码区在线网站 | 亚洲国产精品无码专区在线观看| 中文字幕永久免费| 亚洲AV日韩精品久久久久| 亚洲一级免费毛片| 亚洲一线产品二线产品| www.亚洲色图.com| 精品视频在线免费观看| 亚洲综合色丁香麻豆| 免费看美女让人桶尿口| sss在线观看免费高清| 亚洲一区综合在线播放| 久久天天躁狠狠躁夜夜免费观看| 欧美亚洲精品一区二区| 亚洲中文久久精品无码| AA免费观看的1000部电影| 人人鲁免费播放视频人人香蕉| 亚洲国产成人高清在线观看| 免费看国产精品3a黄的视频 | 亚洲一区二区三区高清不卡| 日韩精品视频免费网址| 中文字幕a∨在线乱码免费看 | 国产va在线观看免费| 亚洲色精品三区二区一区| 亚洲国产一成久久精品国产成人综合 | 亚洲爆乳AAA无码专区|