【正文】
法鼓勵(lì)混合標(biāo)記和業(yè)務(wù)邏輯,很難區(qū)分團(tuán)隊(duì)人員的專業(yè)工作。在運(yùn)行時(shí),容器也能檢測(cè) JSP文件和相應(yīng)的類的最后更新時(shí)間。JavaBean通過(guò)提供符合一致性設(shè)計(jì)模式的公共訪問(wèn)方法將內(nèi)部字段暴露稱為屬性。關(guān)于更多細(xì)節(jié),請(qǐng)參考 JSP標(biāo)簽庫(kù)技術(shù)頁(yè)面。 Accessor 通常以小寫(xiě)的 get 為前綴,后跟屬性名。返回值肯定是邏輯值,不管是 boolean 還是 Boolean。 Model 2: Servlet/JSP 規(guī)范的 版描述了在一個(gè)應(yīng)用中使用 servlet 和 JSP 的架構(gòu)。隨框架也提供一個(gè)豐富的標(biāo)簽庫(kù),以使 Struts 易于和 JSP一起使用。并介紹了一些基本知識(shí),關(guān)于 HTTP, CGI, Java servlet, JSP,以及 JavaBean。根據(jù) Model 2, servlet處理數(shù)據(jù)存取和導(dǎo)航流, JSP處理表現(xiàn)。 On屬性的邏輯訪問(wèn)器的方法體可能是: public boolean isOn() 在使用 JavaBean 時(shí),規(guī)范的方法體簽名扮演了極為重要的角色。返回值必須匹配相應(yīng)的修改器方法的參數(shù)。 xxx大學(xué)畢業(yè)設(shè)計(jì)(論文)外文翻譯 —— 譯文 6 Mutator 通常以小寫(xiě)的 set 前綴開(kāi)始,后跟屬性名。 我們必須做的如下: 1 . 編 寫(xiě) 一 個(gè) 類, 通 過(guò) 實(shí) 現(xiàn) doStart() 或者 doEnd() 方法來(lái)實(shí)現(xiàn) 或者 。項(xiàng)目經(jīng)理現(xiàn)在可以將表現(xiàn)層分派給 HTML 開(kāi)發(fā)人員,將業(yè)務(wù)邏輯工作分派給 JAVA開(kāi)發(fā)人員。為創(chuàng)建 JSP頁(yè)面 , 開(kāi)發(fā)者按創(chuàng)建 HTML頁(yè)面類似的方式創(chuàng)建頁(yè)面,使用相同的 HTML 語(yǔ)法。 (PAnother line of HTML./P)。 一旦 servlet 被創(chuàng)建,使用它處理額外的請(qǐng)求僅帶來(lái)很小的額外開(kāi)銷。 Servlet訪問(wèn) HTTP 特定服務(wù)的 API,但它仍然是一個(gè)運(yùn)行于程序之中的 Java 對(duì)象,并可以利用所有的 Java 資產(chǎn)。這是一個(gè)相對(duì)昂貴的處理方法,對(duì)大容量站點(diǎn)來(lái)說(shuō),每分鐘有數(shù)千個(gè)請(qǐng)求,有可能使站點(diǎn)癱瘓。 公共網(wǎng)關(guān)接口 (CGI): 第一個(gè)普遍用來(lái)產(chǎn)生動(dòng)態(tài)內(nèi)容的標(biāo)準(zhǔn)是通用網(wǎng)關(guān)接口( Common Gateway Interface (CGI))。它主要是使用請(qǐng)求來(lái)定位文件資源,并在響應(yīng)中返回此資源。如上所述, HTTP 并不在請(qǐng)求間保持狀態(tài)信息。 HTTP 請(qǐng)求的第一行包含方法,其后是請(qǐng)求的來(lái)源地址和 HTTP 版本。 HTTP Server 可以接受來(lái)自于各種客戶的各種請(qǐng)求,并提供各種響應(yīng),即使是這個(gè)響應(yīng)僅僅是說(shuō) No。這個(gè)協(xié)議定義數(shù)據(jù)是如何傳輸,以及它們到達(dá)后如何進(jìn)行解碼。對(duì)于你的工具,如果你可以用來(lái)開(kāi)發(fā) Java, 你就可以用它來(lái)開(kāi)發(fā) Struts。如果你自己構(gòu)建它,在你完成時(shí)你就會(huì)理解它,但是在你被融入之前又將花費(fèi)多長(zhǎng)時(shí)間呢?如果要購(gòu)買,你必須得克服學(xué)習(xí)曲線,同樣,在你可以用它進(jìn)行工作之前又得花多長(zhǎng)時(shí)間?這里沒(méi)有所謂正確答案,但許多觀察者都會(huì)同意,象 Struts 這樣的框架能提供比從頭開(kāi)始開(kāi)發(fā)更顯著的投資回報(bào),特別是對(duì)于大型項(xiàng)目來(lái)說(shuō)。 is all too mon in servlets that generate the HTTP response. There are libraries that can help you generate HTML, but as applications grow more plex, Java developers end up being cast into the role of HTML page designers. Meanwhile, given the choice, most project managers prefer to divide development teams into specialized groups. They like HTML designers to be working on the presentation while Java engineers sweat the business logic. Using servlets alone encourages mixing markup with business logic, making it difficult for team members to specialize. To solve this problem, Sun turned to the idea of using server pages to bine scripting and templating technologies into a single ponent. To build Java Server Pages, developers start by creating HTML pages in the same old way, using the same old HTML syntax. To bring dynamic content into the page, the developer can also place JSP scripting elements on the page. Scripting elements are tags that encapsulate logic that is recognized by the JSP. You can easily pick out scripting elements on JSP pages by looking for code that begins with % and ends with %. To be seen as a JSP page, the file just needs to be saved with an extension of .jsp. When a client requests the JSP page, the container translates the page into a source code file for a Java servlet and piles the source into a Java class file— just as you would do if you were writing a servlet from scratch. At runtime, the container can also check the last modified date of the JSP file against the class file. If the JSP file has changed since it was last piled, the container will retranslate and rebuild the page all over again. Project managers can now assign the presentation layer to HTML developers, who then pass on their work to Java developers to plete the businesslogic portion. The important thing to remember is that a JSP page is really just a servlet. Anything you can do with a servlet, you can do with a JSP. 7 JavaBeans: JavaBeans are Java classes which conform to a set of design patterns that make them easier to use with development tools and other ponents. DEFINITION A JavaBean is a reusable software ponent written in Java. To qualify as a JavaBean, the class must be concrete and public, and have a noargument constructor. JavaBeans expose internal fields as properties by providing public methods that follow a consistent design pattern. Knowing that the property names follow this pattern, other Java classes are able to use introspection to discover and manipulate JavaBean properties. The JavaBean design patterns provide access to the bean’s internal state through two flavors of methods: accessors are used to read a JavaBean’s state。象人一樣,軟件應(yīng)用的相似性比不同點(diǎn)要多。這些包括 Lucene 搜索引擎, Scaffold工具包,Struts 驗(yàn)證器,以及 Tiles 標(biāo)簽庫(kù)。開(kāi)發(fā)者使用 Struts 之類的框架是為了隱藏在諸如 HTTP, CGI,以及 JSP之類技術(shù)后面的繁瑣的細(xì)節(jié)。他們?cè)谟?jì)算機(jī)之間維護(hù)一個(gè)持久性的連接。 HTTP 成為通用標(biāo)準(zhǔn)的原因是其簡(jiǎn)單性??梢园?瀏覽器的種類和版本,可接受的文檔類型,瀏覽器的 cookies等等。 Cookies和 URL 重寫(xiě)是兩 個(gè)在請(qǐng)求間跟蹤用戶狀態(tài)的方式。用戶點(diǎn)擊連接將產(chǎn)生另一個(gè)請(qǐng)求,就開(kāi)始一個(gè)新的處理過(guò)程。當(dāng) web服務(wù)器接收到一個(gè)對(duì) CGI程序的請(qǐng)求時(shí),它便運(yùn)行這個(gè)程序并向其提供它請(qǐng)求里面所包含的信息。其次,一次編寫(xiě),隨處運(yùn)行的 JAVA特性意味著 servlet在有 JVM 的操 作系統(tǒng)間是輕便的可移動(dòng)的。每 servlet 都可以聲明它可以處理何種樣式的 URL。 Servlet的另一個(gè)好處是,它是多線程的, servlet開(kāi)發(fā)人員必須特別注意確保它們的 servlet是線程安全的。隨著應(yīng)用越來(lái)越復(fù)雜, Java開(kāi)發(fā)人員將不再扮演 HTML頁(yè)面設(shè)計(jì)的角色。你可以在 JSP 頁(yè)面中很 容易的識(shí)別出腳本元素,他們被封裝在一對(duì) % 和 %標(biāo)記xxx大學(xué)畢業(yè)設(shè)計(jì)(論文)外文翻譯 —— 譯文 5 中。 JavaBean: JavaBean 是一種 Java 類,它遵從一定的設(shè)計(jì)模式,使它們易于和其他開(kāi)發(fā)工具和組件一起使用。 3.在你的 Web 應(yīng)用描述符 ()中定義你的 taglib 元素。簡(jiǎn)單屬性的 mutator 在其方法體中可能只有一個(gè)參數(shù),該參數(shù)可以是各種類型。 屬性 weight 的訪問(wèn)器方法體可能是: public Double getWeight() 如果訪問(wèn)器返回一個(gè)邏輯值,這種情況下有個(gè)變體模式。 Sun引入 JavaBean是為了用于 GUI組件,但它們已經(jīng)用在 Java 開(kāi)發(fā)的各個(gè)方面,包括 Web 應(yīng)用。 HTML開(kāi)發(fā)人員可以改變程序的外觀和感覺(jué),并不需要改變后端 servlet 的