亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 給你一篇ibm的介紹structs的文章(1).txt

?? 《Java技術大合集》,電子書籍都是從網絡上搜集整理成TXT文本文件。收集了:Java Socket編程、JSP語法、WebSphere快速入門等。
?? TXT
字號:
作者:friendcn
日期:2001-2-22 12:46:17
ibm公司的一篇介紹Struts的文章,
覺的不錯,我沒時間翻譯,你要是E文好的話自己看看吧
網址http://www-106.ibm.com/developerworks/library/j-struts/?dwzone=java


Struts, an open-source MVC implementation 
Manage complexity in large Web sites with this servlets and JSP framework

Malcolm Davis
Consultant
February 2001

Contents: 
 Introduction 
 JSP is a servlet 
 No more Java in my HTML 
 MVC 
 MVC Model 2 
 Struts 
 Struts details 
 Mailing list sample 
 Before and after 
 Future of Struts 
  Resources 
 About the author 
 


This article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help you control change in your Web project and promote specialization. Even if you never implement a system with Struts, you may get some ideas for your future servlets and JSP page implementations.

Introduction
Kids in grade school put HTML pages on the Internet. However, there is a monumental difference between a grade school page and a professionally developed Web site. The page designer (or HTML developer) must understand colors, the customer, product flow, page layout, browser compatibility, image creation, JavaScript, and more. Putting a great looking site together takes a lot of work, and most Java developers are more interested in creating a great looking object interface than a user interface. JavaServer Pages (JSP) technology provides the glue between the page designer and the Java developer. 

If you have worked on a large-scale Web application, you understand the term change. Model-View-Controller (MVC) is a design pattern put together to help control change. MVC decouples interface from business logic and data. Struts is an MVC implementation that uses Servlets 2.2 and JSP 1.1 tags, from the J2EE specifications, as part of the implementation. You may never implement a system with Struts, but looking at Struts may give you some ideas on your future Servlets and JSP implementations.

In this article, I will begin with a JSP file that uses elements you may be familiar with and discuss the pros and cons of such a page. I will then cover Struts and how it can control change in your Web project and promote specialization. Finally, I will re-develop the simple JSP file with the page designer and change in mind. 

A JSP file is a Java servlet 
A JavaServer Page (JSP) file is nothing more than another way to view a servlet. The concept of a JSP file is to allow us to see a Java servlet as an HTML page. This view eliminates all of the ugly print() statements that normally show up in Java code. The JSP file is pre-processed into a .java file, then compiled into a .class. If you are using Tomcat, you can view your pre-processed .java files in the work directory. Other containers may store the .java and .class files elsewhere; the location is container specific. Figure 1 demonstrates the JSP file-to-servlet flow. 

Figure 1. JSP file-to-servlet flow


(This is significantly different from a Microsoft Active Server Page (ASP). An ASP is compiled into memory, not into a separate file.)

The simple self-contained JSP file
In a small JSP application, it is common to see the data, business logic, and the user interface combined into one module of code. In addition, the application generally contains the logic that controls the flow of the application. Listing 1 and Figure 2 demonstrate a simple JSP file that allows a user to join a mailing list.

Listing 1. join.jsp -- a simple request and response JSP file <%@ page language="java" %>
<%@ page import="business.util.Validation" %>
<%@ page import="business.db.MailingList" %>
<%
String error = "";
String email = request.getParameter("email");

// do we have an email address
if( email!=null ) {

    // validate input...
    if( business.util.Validation.isValidEmail(email) ) {

        // store input...
        try {
            business.db.MailingList.AddEmail(email);
        } catch (Exception e) {
            error = "Error adding email address to system.  " + e;
        }

        if( error.length()==0 ) {
%>
            // redirect to welcome page...
            <jsp:forward page="welcome.html"/> 
<%
        }
    } else {
        // set error message and redisplay page
        error = email + " is not a valid email address, please try again.";
    }

} else {
    email = "";
}
%>
<html>
<head>
<title>Join Mailing List</title>
</head>
<body>
<font color=red><%=error%></font><br>

<h3>Enter your email to join the group</h3>
<form action="join.jsp" name="joinForm">
    <input name="email" id="email" value=<%=email%>></input> 
    <input type=submit value="submit">
</form>
</body>
</html>

 


Figure 2. In a simple request and response, the JSP file sets the data, controls the flow to the next page, and creates the HTML


The mailing list JSP file is a self-contained, do-it-all module. The only things not contained in the JSP file are the actual code for validation that is contained in isValidEmail() and the code that puts the e-mail address in the database. (Separating the isValidEmail() method into reusable code might seem like an obvious thing to do, but I have seen the code for isValidEmail() embedded directly into the page.) The advantage of the single-page approach is that it is easy to understand and initially easy to build. In addition, with all the graphical development tools, it is easy to get started. 

Activities of join.jsp


Display opening input page. 
Read the email value from the form parameter. 
Validate the email address. 
If email address is valid: 
Add the address to the database. 
Redirect to the next page. 
If email address is invalid: 
Set an error message. 
Redisplay join.jsp with the error message. 

Consequences of the single-page approach 

Heavy HTML and Java coupling
The coder of the JSP file must be both a page designer and a Java developer. The result is often either terrible Java code or an ugly page, or sometimes both.


Java and JavaScript blur
As the pages become larger, there can be a tendency to implement some JavaScript. When the JavaScript appears in a page, the script can get confused with the Java code. An example of a possible point of confusion is using client-side JavaScript to validate the email field.


Embedded flow logic
To understand the entire flow of the application, you have to navigate all of the pages. Imagine the spaghetti logic on a 100-page Web site.


Debugging difficulties
In addition to being ugly to look at, HTML tags, Java code, and JavaScript code all in one page makes it difficult to debug problems.


Tight coupling
Changes to business logic or data means possibly touching every page involved. 


Aesthetics
Visually, in large pages, this type of coding looks messy. When I was doing Microsoft ASP development, I would commonly see 1000-line pages. Even with syntax coloring, it was still difficult to read and understand. 

No more Java code in my HTML, please
In Listing 1, instead of having a lot of HTML in Java code, I have a lot of Java code in an HTML file. From this standpoint, I really have not accomplished much, other than permit page designers to write Java code. However, all is not lost; with JSP 1.1, we got a new feature called tags. 

A JSP tag is simply a way of abstracting out code from a JSP file. Some people think of JSP tags as macros for JSP files, where the code for the tag is contained in the servlet. (The macro perspective is almost true.) For the same reason I do not want to see HTML tags in Java code, I do not want to see Java code in a JSP file. The entire point of JSP technology is to allow the page designer to create servlets without being distracted with Java code. Tags allow Java programmers to extend JSP files by making Java code look like HTML. Figure 3 displays the general concept of pulling the code from the JSP page and putting into a JSP tag.

Figure 3. JSP tag


An example of Struts tag capability is in Listing 2. In Listing 2, the normal HTML <form> tag is replaced with the Struts <form:form> tag. Listing 3 shows the resulting HTML that the browser receives. The browser gets the HTML <form> tag, but with additional code, such as the JavaScript. The additional JavaScript sets the focus on the email address field. The server side <form:form> tag code created the appropriate HTML and abstracts the JavaScript away from the page designer. 

Listing 2. Struts form tag

<form:form action="join.do" focus="email" >
    <form:text   property="email" size="30" maxlength="30"/>
    <form:submit property="submit" value="Submit"/>
</form:form>

 


Listing 3. Resulting HTML sent to the browser
<form name="joinForm" method="POST" action="join.do;jsessionid=ndj71hjo01">
    <input type="text" name="email" maxlength="30" size="30" value="">
    <input type="submit" name="submit" value="Submit">
</form>
<script language="JavaScript">
<!--
    document.joinForm.email.focus()
// -->
</script>


 


Notes about JSP tags: 

JSP tags require a container that runs JSP 1.1 or later.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久精品免费网站| 国产精品免费aⅴ片在线观看| 国产精品女同一区二区三区| 日本少妇一区二区| 欧美撒尿777hd撒尿| 一区二区三区中文在线观看| 成人丝袜高跟foot| 久久综合九色综合欧美亚洲| 国产伦精一区二区三区| 4438亚洲最大| 午夜精品久久久久久久蜜桃app| 色8久久人人97超碰香蕉987| 久久久综合精品| 成人网在线播放| 国产精品情趣视频| 91亚洲永久精品| 中文字幕在线观看不卡视频| 亚洲一区二区三区四区在线| 91欧美一区二区| 日韩一区在线播放| 色综合久久99| 午夜欧美视频在线观看| 91超碰这里只有精品国产| 午夜精品久久久久久不卡8050| 欧美日免费三级在线| 日韩电影在线一区二区| 精品粉嫩aⅴ一区二区三区四区| 狠狠色狠狠色综合| 国产色一区二区| 在线亚洲高清视频| 日韩综合小视频| 91麻豆精品国产91久久久| 国产精品一区二区在线观看网站| 国产精品丝袜久久久久久app| 99久久国产综合精品女不卡| 亚洲精品免费播放| 欧美精品精品一区| 成人午夜在线免费| 日韩美女精品在线| 在线观看亚洲专区| 极品少妇xxxx精品少妇| 中文一区一区三区高中清不卡| 成人黄色软件下载| 麻豆精品在线视频| 欧美国产一区二区| 欧美日韩国产一级二级| 精品制服美女丁香| 一二三四区精品视频| 欧美zozozo| 色哟哟欧美精品| 黄色小说综合网站| 一区二区三区波多野结衣在线观看| 欧美tk—视频vk| 99视频精品全部免费在线| 一区二区三区欧美日韩| 国产欧美一区二区精品秋霞影院| 91小视频免费看| 国内精品久久久久影院薰衣草| 亚洲精品乱码久久久久久黑人 | 一本到不卡免费一区二区| 中文av字幕一区| 欧美人动与zoxxxx乱| 从欧美一区二区三区| 欧美bbbbb| 一区二区三区欧美视频| 欧美一区二区在线观看| 91国内精品野花午夜精品| 国模无码大尺度一区二区三区| 天天综合色天天综合| 亚洲人成网站影音先锋播放| 精品国产伦一区二区三区观看体验| 在线视频国产一区| 成人app网站| 成人一区在线看| 久久国产日韩欧美精品| 亚洲乱码国产乱码精品精小说 | 激情国产一区二区| 亚洲一二三专区| 国产精品女主播在线观看| 久久免费看少妇高潮| 欧美精品久久久久久久多人混战| 色综合久久综合网欧美综合网| 国产乱一区二区| 日韩不卡一区二区| 美国av一区二区| 丝袜美腿亚洲一区二区图片| 夜夜嗨av一区二区三区| 一区二区日韩av| **欧美大码日韩| 亚洲精品一二三| 亚洲精品视频在线观看免费| 国产精品久久久久久福利一牛影视| 久久嫩草精品久久久久| 日韩免费性生活视频播放| 色综合中文字幕国产| 国产91精品久久久久久久网曝门| 精品一区二区在线看| 国产99久久久久久免费看农村| 久久99国内精品| 久久精品国产成人一区二区三区 | 日韩在线观看一区二区| 亚洲综合丝袜美腿| 一区二区三区四区在线免费观看 | 欧美成人a视频| 欧美刺激午夜性久久久久久久| www国产成人| 久久网站热最新地址| 久久影院午夜片一区| 国产亚洲一本大道中文在线| 精品国产伦理网| 久久精品欧美一区二区三区不卡 | 国产欧美日韩视频一区二区| 国产亚洲va综合人人澡精品| 精品国产亚洲一区二区三区在线观看| 久久久美女毛片| 中文字幕欧美区| 亚洲综合色视频| 天天综合网天天综合色| 国产成人欧美日韩在线电影| 成人影视亚洲图片在线| 色婷婷亚洲精品| 日韩视频一区二区在线观看| 亚洲精品一区二区三区蜜桃下载| 中文字幕欧美三区| 亚洲欧美一区二区不卡| 亚洲成a人片在线不卡一二三区| 日韩av在线免费观看不卡| 国产自产v一区二区三区c| 成人av在线播放网站| 日本伦理一区二区| 日韩精品一区在线观看| 欧美成人伊人久久综合网| 国产精品狼人久久影院观看方式| 亚洲人成人一区二区在线观看| 亚洲国产精品综合小说图片区| 国产一区中文字幕| 99久久777色| 精品久久久久香蕉网| 亚洲欧美偷拍卡通变态| 韩国精品久久久| 色伊人久久综合中文字幕| 日本韩国欧美三级| 国产日韩av一区二区| 亚洲国产精品麻豆| 国产最新精品免费| 国产不卡视频一区二区三区| 99re成人精品视频| 久久影院视频免费| 一区二区三区四区精品在线视频| 国产成a人亚洲精品| 欧美精品丝袜久久久中文字幕| 欧美亚洲一区二区在线| 亚洲色图在线看| 免费看日韩a级影片| 欧美三级电影精品| 中文天堂在线一区| 国产一区激情在线| 欧美日韩和欧美的一区二区| 日本一区二区三区在线不卡| 久久99这里只有精品| 欧美中文字幕一区| 一区二区三区高清在线| 国产精品18久久久久久久久久久久| 91亚洲精品久久久蜜桃网站| 精品国产免费久久 | 欧美日韩日日夜夜| 亚洲激情校园春色| 国产成+人+日韩+欧美+亚洲| 久久婷婷国产综合精品青草| 亚洲国产成人av好男人在线观看| 久久国产综合精品| 日韩一区二区三| 亚洲国产综合视频在线观看| 欧美综合一区二区三区| 中文字幕不卡的av| 成人在线视频首页| 久久久国产精华| 久久不见久久见免费视频1| 欧美日韩午夜影院| 亚洲曰韩产成在线| 制服丝袜中文字幕一区| 亚洲一卡二卡三卡四卡五卡| 欧洲人成人精品| 亚洲综合无码一区二区| jizzjizzjizz欧美| 亚洲精品久久久久久国产精华液| 国产成人精品免费| 亚洲视频一区在线观看| av在线一区二区三区| 成人欧美一区二区三区黑人麻豆| 国产91富婆露脸刺激对白| 欧美一区二区高清| 极品美女销魂一区二区三区免费| 欧美一级高清大全免费观看| 精品中文字幕一区二区| 26uuu国产在线精品一区二区| 激情成人综合网| 中文在线免费一区三区高中清不卡| 91啪在线观看| 亚洲在线观看免费|