?? ws-j2x-2-1.html
字號:
<html> <!-- This panel generated from the developerWorks XML tag set for tutorials, Version 2.0.0. (C) Copyright 2000, 2001 IBM Corporation. All rights reserved. --> <head><META http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>循序漸進的 Servlet 示例</title>
<style type="text/css"><!--
body { color: #000000; background-color: #ffffff; }
dt { font-weight: bold; }
code { font-family: Courier, monospace; font-size: +2; }
titleCode { font-family: Courier, monospace; font-size: +4; }
ol.alpha { list-style-type: upper-alpha; }
span.center { text-align: center; }
span.right { text-align: right; }
span.constant { color: #990099; }
span.keyword { color: #993333; }
span.function-name { color: #666633; }
span.comment { color: #666666; }
span.string { color: #0000ff; }
span.variable-name { color: #000066; }
span.type { color: #006600; }
span.spacer { font-size: 1pt; }
.small { font-family: Verdana, sans-serif; font-size: 8pt }
.divider { color: #999999; font-family: Verdana, Arial, sans-serif; font-weight: normal }
a.mainlink:link { text-decoration: none; color: #ffffff; font-family: Verdana, Arial, sans-serif; font-weight: bold; font-size: 8pt }
a.mainlink:visited { text-decoration: none; color: #ffffff; font-family: Verdana, Arial, sans-serif; font-weight: bold; font-size: 8pt }
a.mainlink:hover { text-decoration: underline; color: #ffffff; font-family: Verdana, Arial, sans-serif; font-weight: bold; font-size: 8pt }
.hbg { background-color : #006699; background-image: url(../i/lines.gif) ;background-repeat: repeat; }
.tbg { background-color : #006699; background-image: url(../i/gr760.gif); }
.tbgc { background-color : #006699 }
.bbg { background-color : #000000; vertical-align: middle }
.dbg { background-color : #6699cc }
.mbg { background-color : #99ccff }
.lbg { background-color : #cce5ff }
-->
</style>
</head>
<body bgcolor="ffffff">
<script language="javascript">
<!-- var emailAbstract="本教程為 J2EE 開發(fā)者講述如何使用 XDoclet 來加速開發(fā)。XDoclet 使用面向?qū)傩跃幊虂砗喕M件之間的連續(xù)集成。通過生成部署描述符和支持代碼,它使您能夠大大地減少開發(fā)時間,從而使您能夠把重點放在應(yīng)用程序邏輯代碼上。";
var justTitle="用 XDoclet 來改進 J2EE 組件的重用";
var tutorialPrereqs="http://www-106.ibm.com/developerworks/education/ws-j2x";
var menu1blurb="關(guān)于本教程";
var menu2blurb="循序漸進的 Servlet 示例";
var menu3blurb="循序漸進的定制標記示例(標記庫)";
var menu4blurb="循序漸進的 EJB 技術(shù)示例";
var menu5blurb="xPetstore";
var menu6blurb="總結(jié)";
var browser = "x";
if (navigator.userAgent.indexOf("Mozilla/4") != -1) browser = "N3";
else if (navigator.userAgent.indexOf("Mozilla/3") != -1) browser = "N3";
else browser = "x";
if (browser=="N3")
{
var menu1over=new Image(108,68);
var menu1out=new Image(108,68);
var menu2over=new Image(108,68);
var menu2out=new Image(108,68);
var menu3over=new Image(108,68);
var menu3out=new Image(108,68);
var menu4over=new Image(108,68);
var menu4out=new Image(108,68);
var menu5over=new Image(108,68);
var menu5out=new Image(108,68);
var menu6over=new Image(108,68);
var menu6out=new Image(108,68);
var topmainover=new Image(77,15);
var topmainout=new Image(77,15);
var bottommainover=new Image(77,15);
var bottommainout=new Image(77,15);
var topsectionover=new Image(98,15);
var topsectionout=new Image(98,15);
var bottomsectionover=new Image(98,15);
var bottomsectionout=new Image(98,15);
var topfeedbackover=new Image(80,15);
var topfeedbackout=new Image(80,15);
var bottomfeedbackover=new Image(80,15);
var bottomfeedbackout=new Image(80,15);
var toppreviousover=new Image(77,15);
var toppreviousout=new Image(77,15);
var bottompreviousover=new Image(77,15);
var bottompreviousout=new Image(77,15);
var topnextover=new Image(60,15);
var topnextout=new Image(60,15);
var bottomnextover=new Image(60,15);
var bottomnextout=new Image(60,15);
var topnextsectionover=new Image(108,15);
var topnextsectionout=new Image(108,15);
var bottomnextsectionover=new Image(108,15);
var bottomnextsectionout=new Image(108,15);
menu1over.src="imagemaster/himenu1.jpg";
menu1out.src="imagemaster/menu1.jpg";
menu2over.src="imagemaster/himenu2.jpg";
menu2out.src="imagemaster/menu2.jpg";
menu3over.src="imagemaster/himenu3.jpg";
menu3out.src="imagemaster/menu3.jpg";
menu4over.src="imagemaster/himenu4.jpg";
menu4out.src="imagemaster/menu4.jpg";
menu5over.src="imagemaster/himenu5.jpg";
menu5out.src="imagemaster/menu5.jpg";
menu6over.src="imagemaster/himenu6.jpg";
menu6out.src="imagemaster/menu6.jpg";
var mainblurb="主菜單";
var sectionblurb="章節(jié)菜單";
var feedbackblurb="提交反饋意見";
var previousblurb="上一屏";
var nextblurb="下一屏";
var nextsectionblurb="下一章";
topmainover.src="../i/h-main.gif";
topmainout.src="../i/main.gif";
bottommainover.src="../i/h-main.gif";
bottommainout.src="../i/main.gif";
topsectionover.src="../i/h-section.gif";
topsectionout.src="../i/section.gif";
bottomsectionover.src="../i/h-section.gif";
bottomsectionout.src="../i/section.gif";
topfeedbackover.src="../i/h-feedback.gif";
topfeedbackout.src="../i/feedback.gif";
bottomfeedbackover.src="../i/h-feedback.gif";
bottomfeedbackout.src="../i/feedback.gif";
toppreviousover.src="../i/h-previous.gif";
toppreviousout.src="../i/previous.gif";
bottompreviousover.src="../i/h-previous.gif";
bottompreviousout.src="../i/previous.gif";
topnextover.src="../i/h-next.gif";
topnextout.src="../i/next.gif";
bottomnextover.src="../i/h-next.gif";
bottomnextout.src="../i/next.gif";
topnextsectionout.src="../i/nextsection.gif";
topnextsectionover.src="../i/h-nextsection.gif";
bottomnextsectionout.src="../i/nextsection.gif";
bottomnextsectionover.src="../i/h-nextsection.gif";
}
function iOut(image)
{
if (browser=="N3")document[image].src=eval(image + "out.src");
}
function iOver(image)
{
if (browser=="N3")document[image].src=eval(image + "over.src");
}
// -->
</script><a href="#navskip"><img border="0" alt="Skip to main content" src="../i/c.gif"></a>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td class="tbgc" width="160"><a href="/developerWorks/cgi-bin/click.cgi?url=http://www.ibm.com/cn"><img height="47" width="160" alt="IBM" border="0" src="../i/ibm-logo.gif"></a></td><td class="tbg" width="195"><font color="#99ccff" size="2"><b>中國</b></font><a href="#main"><img alt="Skip to main content" height="1" width="195" border="0" src="../i/c.gif"></a></td><td valign="top" align="right" class="tbgc" width="100%">
<table cellspacing="0" cellpadding="0" border="0">
<form name="form1" id="form1" action="http://202.95.2.149/cgi-bin/dWsearch.pl" method="get">
<tr>
<td colspan="6"><img alt="" height="4" width="390" border="0" src="../i/c.gif"></td>
</tr>
<tr valign="middle">
<td class="dwsearch" height="8"><select class="dwsearch" name="selScope"><option value="dW">dW 中國所有內(nèi)容</option><option value="dW">................. </option><option value="dW">dW 中國技術(shù)專區(qū):</option><option value="comptZ"> 組件技術(shù)</option><option value="javaZ"> Java 技術(shù)</option><option value="linuxZ"> Linux</option><option value="xmlZ"> XML</option><option value="linuxZ">dW 中國特別專題:</option><option value="securityZ"> 安全</option><option value="unicodeZ"> Unicode</option><option value="all">IBM 全部內(nèi)容</option></select></td><td class="small"><img alt="" border="0" height="1" width="5" src="../i/c.gif"></td><td><input maxlength="100" size="15" height="15" name="UserRestriction" class="dwsearch" type="text"></td><td><img alt="" height="1" width="5" border="0" src="../i/c.gif"></td><td width="64"><input alt="搜索" name="Search" value="Search" border="0" height="23" width="64" src="../i/search.gif" type="image"></td><td valign="top"><img alt="" height="1" width="34" border="0" src="../i/c.gif"></td>
</tr>
<tr valign="top">
<td class="small" colspan="6"><a target="_blank" style="color: #ffffff;" href="http://202.95.2.149/help.htm">高級搜索</a><img alt="" height="1" width="1" border="0" src="../i/c.gif"></td>
</tr>
<tr>
<td colspan="6"><img alt="" height="4" width="390" border="0" src="../i/c.gif"></td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td class="hbg" height="21" width="160"></td><td class="bbg" valign="top" height="21" colspan="2"> <a href="/developerWorks/cgi-bin/click.cgi?url=http://www-900.ibm.com/cn/" class="mainlink">IBM 主頁</a><span class="divider"> | </span><a href="/developerWorks/cgi-bin/click.cgi?url=http://www-900.ibm.com/cn/products/index.shtml" class="mainlink">產(chǎn)品與服務(wù)</a><span class="divider"> | </span><a href="/developerWorks/cgi-bin/click.cgi?url=http://www-900.ibm.com/cn/support/index.shtml" class="mainlink">支持與下載</a><span class="divider"> | </span><a href="/developerWorks/cgi-bin/click.cgi?url=http://www-900.ibm.com/cn/account/index.shtml" class="mainlink">個性化服務(wù)</a></td>
</tr>
</table>
<TABLE width="100%" cellspacing="0" cellpadding="0" border="0">
<TR>
<TD bgcolor="#ffffff" height="1" width="150"><IMG src="../i/c.gif" width="150" height="1"></TD>
</TR>
<TR>
<TD bgcolor="#cc6633" height="3" width="150"><IMG src="../i/c.gif" width="150" height="3"></TD>
</TR>
<TR>
<TD bgcolor="#333333" height="1" width="150"><IMG src="../i/c.gif" width="150" height="1"></TD>
</TR>
<TR>
<TD bgcolor="#000000" height="1" width="150"><IMG src="../i/c.gif" width="150" height="1"></TD>
</TR>
<TR>
<TD bgcolor="#ffffff" height="1" width="150"><IMG src="../i/c.gif" width="150" height="2"></TD>
</TR>
</TABLE>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><font size="-1" face="Verdana, sans-serif"><a href="http://www.ibm.com/">IBM</a> : <a href="/developerWorks/cn/index.shtml">developerWorks 中國網(wǎng)站</a> : <a href="/developerWorks/cn/xml/index.shtml">xml</a> : <a href="/developerWorks/cn/cnedu.nsf/xml-onlinecourse-bytitle">教學 - 在線教程</a></font>
<br>
<img alt="用 XDoclet 來改進 J2EE 組件的重用" src="imagemaster/masthead.jpg"></td><td width="*" valign="bottom" align="right"><a border="0" href="ws-j2x.zip"><img alt="下載 ZIP 文件" border="0" src="../i/icon-zip.gif"></a><a target="_blank" href="../tutorial_eng/index.html" border="0"><img alt="英文原文" border="0" src="../i/icon-source.gif"></a>
</td>
</tr>
<tr>
<td height="2" colspan="2"><img height="2" width="1" src="../i/c.gif"></td>
</tr>
</table>
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TD width="150" height="1" bgcolor="#000000" colspan="6"><IMG alt="" height="1" width="150" src="../i/c.gif"></TD>
</TR>
<TR>
<TD background="../i/sw-gold.gif"><a border="0" href="index.html" onMouseOver="iOver('topmain'); iOver('bottommain'); self.status=mainblurb; return true;" onMouseOut="iOut('topmain'); iOut('bottommain'); self.status=''; return true;"><img alt="主菜單" border="0" src="../i/main.gif" name="topmain"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topsection'); iOver('bottomsection'); self.status=sectionblurb; return true;" onMouseOut="iOut('topsection'); iOut('bottomsection'); self.status=''; return true;" href="index2.html"><img alt="章節(jié)菜單" border="0" src="../i/section.gif" name="topsection"></a></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topfeedback'); iOver('bottomfeedback'); self.status=feedbackblurb; return true;" onMouseOut="iOut('topfeedback'); iOut('bottomfeedback'); self.status=''; return true;" href="ws-j2x-6-3.html"><img alt="給出此教程的反饋意見" border="0" src="../i/feedback.gif" name="topfeedback"></a></TD><TD width="100%" background="../i/sw-gold.gif"><img src="../i/c.gif"></TD><TD background="../i/sw-gold.gif"><img border="0" src="../i/xprevious.gif"></TD><TD background="../i/sw-gold.gif"><a border="0" onMouseOver="iOver('topnext'); iOver('bottomnext'); self.status=nextblurb; return true;" onMouseOut="iOut('topnext'); iOut('bottomnext'); self.status=''; return true;" href="ws-j2x-2-2.html"><img alt="下頁" border="0" src="../i/next.gif" name="topnext"></a></TD>
</TR>
</TABLE>
<table bgcolor="ffffff" cellspacing="0" cellpadding="2" border="0" height="400" width="100%">
<tr valign="bottom">
<a name="navskip"></a><td height="25" colspan="4"><img alt="2.循序漸進的 Servlet 示例" src="imagemaster/titlebar2.jpg" border="0" height="25" width="562"></td>
</tr>
<tr>
<td bgcolor="ffffff" width="15"> </td><td bgcolor="ffffff" width="12"> </td><td valign="top" align="left" bgcolor="ffffff" width="*">
<p>
<br>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="90%"><font size="4" face="Verdana, Arial, Helvetica"><b>Servlet XDoclet 示例</b></font></td><td width="200" align="right"><font size="1" face="Verdana, Arial, Helvetica"><nobr> 第 1 頁(共14 頁)</nobr></font></td>
</tr>
</table>
<br>
<br>
</p>
<font size="2" face="Verdana, Arial, Helvetica">
<p>現(xiàn)在本教程開始了,我們先講述簡單的 Servlet 和 XDoclet 組合。別忘了 XDoclet 擴展了 JavaDoc 引擎的概念從而使您能夠根據(jù)定制 JavaDoc 標記來生成代碼和其它文件。XDoclet 附帶的 Ant 任務(wù)使您能夠創(chuàng)建 <i>web.xml</i> 文件、ejb-jar.xml 文件和許多其它文件。在這一部分中,您將使用 XDoclet 和 <b>webdoclet</b> Ant 任務(wù)來生成 Web 應(yīng)用程序部署描述符。這是本教程中最簡單的嘗試。請注意標準的 Ant 分發(fā)版沒有附帶 XDoclet Ant 任務(wù)。</p>
<p>如果您以前用過 J2EE 技術(shù),那么您知道 <i>web.xml</i> 文件是用來配置 Web 應(yīng)用程序的。<i>web.xml</i> 文件是 Web 應(yīng)用程序的部署描述符。XDoclet 使您能夠在 Servlet 源代碼中使用類似 JavaDoc 的標記來生成 <i>web.xml</i> 部署描述符。</p>
<p>以下 Servlet 指定了被用來生成 <i>web.xml</i> 文件的 XDoclet 標記。我們來快速地預(yù)覽一下,然后我將詳細介紹這些標記如何映射到 Web 應(yīng)用程序部署描述符(<i>web.xml</i>)中生成的元素。
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -