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

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

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

?? 包含很多java文章
?? 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一区二区三区免费野_久草精品视频
欧美丝袜自拍制服另类| 色综合天天综合网天天狠天天| 亚洲欧美日韩一区二区| 欧美激情一区二区三区蜜桃视频| 久久亚洲一区二区三区明星换脸| 日韩女优电影在线观看| 日韩欧美黄色影院| 精品国内二区三区| 欧美精品一区二区三区很污很色的 | 国产午夜亚洲精品羞羞网站| 久久综合九色综合欧美亚洲| 久久老女人爱爱| 国产网站一区二区| 国产精品灌醉下药二区| 亚洲区小说区图片区qvod| 亚洲女爱视频在线| 午夜婷婷国产麻豆精品| 三级亚洲高清视频| 精彩视频一区二区| 成人国产精品视频| 欧美中文字幕一区二区三区| 欧美一区中文字幕| 亚洲伦在线观看| 青草av.久久免费一区| 日韩激情视频网站| 久久99在线观看| 成人夜色视频网站在线观看| 91麻豆福利精品推荐| 在线不卡欧美精品一区二区三区| 日韩欧美一级片| 国产精品电影一区二区三区| 亚洲无线码一区二区三区| 久久精品国产亚洲5555| 国产91在线看| 欧美日韩国产一级二级| 2017欧美狠狠色| 亚洲国产一区在线观看| 激情丁香综合五月| 91日韩在线专区| 91精品蜜臀在线一区尤物| 国产精品无圣光一区二区| 天天色综合天天| 不卡一区在线观看| 欧美一级欧美三级| 国产精品看片你懂得| 美女精品一区二区| 91年精品国产| 精品久久久久香蕉网| 一区二区三区国产豹纹内裤在线| 国内外成人在线视频| 色欧美乱欧美15图片| 久久久久综合网| 午夜av区久久| 色婷婷av一区二区三区gif | 美国毛片一区二区三区| 在线视频国内一区二区| 国产校园另类小说区| 青青草国产精品亚洲专区无| 在线观看视频91| 国产精品电影一区二区三区| 国产一区二区三区久久悠悠色av | 美腿丝袜亚洲综合| 欧美性生活大片视频| 亚洲天堂免费看| 成人禁用看黄a在线| 久久伊99综合婷婷久久伊| 美女视频黄久久| 欧美一级午夜免费电影| 午夜精品一区二区三区电影天堂| 色老汉av一区二区三区| 国产精品第五页| 成人av在线影院| 一区在线中文字幕| 成a人片国产精品| 欧美国产一区在线| 春色校园综合激情亚洲| 日本一区二区三区国色天香| 国产一区高清在线| 久久久久9999亚洲精品| 国产福利一区二区三区| 国产精品沙发午睡系列990531| 国产成人一级电影| 欧美国产日韩一二三区| 懂色av中文一区二区三区 | 一本一道综合狠狠老| 国产精品传媒入口麻豆| 91免费精品国自产拍在线不卡| 国产精品嫩草99a| 91社区在线播放| 亚洲综合色婷婷| 欧美一区二区三区的| 久久成人av少妇免费| 26uuu亚洲综合色| 高清成人在线观看| 一区二区三区在线免费观看| 欧美日韩一区三区四区| 人禽交欧美网站| 国产欧美视频在线观看| 99re视频精品| 丝袜美腿亚洲一区二区图片| 日韩一区二区在线看片| 国内精品视频一区二区三区八戒| 欧美国产综合一区二区| 欧美特级限制片免费在线观看| 日本欧美加勒比视频| 欧美激情一区三区| 欧美午夜精品电影| 久色婷婷小香蕉久久| 日韩美女久久久| 欧美一级一区二区| av午夜精品一区二区三区| 亚洲电影在线播放| 精品久久久久久亚洲综合网| 粉嫩aⅴ一区二区三区四区五区| 亚洲精品国产第一综合99久久| 91精品国产综合久久婷婷香蕉 | 捆绑调教美女网站视频一区| 一区在线中文字幕| 日韩女优毛片在线| 91福利视频久久久久| 国产福利91精品| 日韩成人精品在线观看| 亚洲欧美另类小说| 精品久久久久久久一区二区蜜臀| 色爱区综合激月婷婷| 国产成人日日夜夜| 日本女人一区二区三区| 亚洲免费视频中文字幕| 久久―日本道色综合久久| 欧美军同video69gay| 成人污视频在线观看| 麻豆久久久久久| 亚洲成av人片在线观看| 亚洲欧美自拍偷拍| 久久精品视频免费观看| 日韩一区二区精品葵司在线| 色久综合一二码| 成人av免费在线观看| 国产一区视频导航| 久久精品国产免费| 丝袜亚洲另类丝袜在线| 亚洲精品美腿丝袜| 国产精品水嫩水嫩| 国产欧美久久久精品影院| 91精品在线免费| 欧美高清视频在线高清观看mv色露露十八| 99精品欧美一区二区三区综合在线| 国产一区二区在线观看免费| 久久se这里有精品| 蜜桃视频免费观看一区| 丝瓜av网站精品一区二区 | 久草中文综合在线| 麻豆91精品91久久久的内涵| 日本成人在线不卡视频| 日精品一区二区三区| 亚洲v日本v欧美v久久精品| 亚洲在线观看免费| 一区二区三区蜜桃网| 亚洲午夜精品在线| 亚洲午夜私人影院| 午夜精品一区在线观看| 偷偷要91色婷婷| 日产欧产美韩系列久久99| 美女诱惑一区二区| 国产精品主播直播| 国产经典欧美精品| 成人v精品蜜桃久久一区| www.欧美.com| 一本久久综合亚洲鲁鲁五月天| 色综合久久中文字幕综合网 | 久久狠狠亚洲综合| 国产精品亚洲综合一区在线观看| 国产精品1区2区| 91麻豆免费观看| 91麻豆精品国产综合久久久久久| 欧美一二三区在线| 久久婷婷色综合| 1区2区3区国产精品| 亚洲国产精品精华液网站| 蜜桃视频在线观看一区| 成人夜色视频网站在线观看| 日本乱码高清不卡字幕| 欧美男人的天堂一二区| 久久久综合九色合综国产精品| 国产精品久久一级| 亚洲第一福利一区| 国产成人精品亚洲777人妖| 色婷婷av久久久久久久| 日韩欧美久久久| 亚洲精选视频免费看| 日本免费在线视频不卡一不卡二| 国产精品夜夜嗨| 欧美日韩dvd在线观看| 国产日产精品一区| 婷婷国产在线综合| 成av人片一区二区| 精品久久人人做人人爰| 亚洲激情图片一区| 国产成人自拍在线| 日韩视频一区在线观看|