亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲欧洲制服丝袜| 国产精品高清亚洲| 日韩精品乱码av一区二区| 99久久精品国产观看| 国产欧美日韩视频在线观看| 国产在线视视频有精品| 精品国产亚洲一区二区三区在线观看| 三级久久三级久久久| 欧美人与禽zozo性伦| 亚洲成人av中文| 欧美日韩国产美| 日韩电影免费在线| 日韩一区二区在线观看| 麻豆免费精品视频| 精品国产一区二区国模嫣然| 国产在线不卡一区| 国产肉丝袜一区二区| 不卡一区在线观看| 一区二区免费在线播放| 欧美在线视频不卡| 亚洲成精国产精品女| 欧美日韩国产一二三| 日韩电影在线一区二区三区| 欧美一区二区美女| 久久91精品国产91久久小草| 久久毛片高清国产| 99久久精品久久久久久清纯| 日韩美女久久久| 欧美日免费三级在线| 丝袜美腿高跟呻吟高潮一区| 日韩精品专区在线| 国产成人精品一区二区三区网站观看| 久久久精品天堂| 99re热视频这里只精品| 中文字幕久久午夜不卡| 欧美日韩国产a| 日韩av午夜在线观看| 欧美电影免费观看高清完整版| 久久99精品久久久久久国产越南| 久久久精品综合| 色综合久久久网| 日韩国产高清影视| 久久久久久麻豆| 91视视频在线观看入口直接观看www | 欧美精品 日韩| 久久99国产精品免费网站| 中文欧美字幕免费| 日本精品一区二区三区高清| 首页国产欧美久久| 国产亚洲欧美色| 欧美视频一区在线观看| 国产在线精品一区二区夜色| 亚洲欧美在线观看| 欧美一区二区三区四区五区| 国产sm精品调教视频网站| 一区二区成人在线观看| 欧美电影免费观看高清完整版在线观看 | 亚洲免费成人av| 亚洲国产一区视频| 亚洲国产精品欧美一二99| 国产v综合v亚洲欧| 欧美三区免费完整视频在线观看| 中文幕一区二区三区久久蜜桃| 亚洲成av人片观看| 欧美三级一区二区| 日本女人一区二区三区| 久久精品一二三| 在线免费观看日本一区| 国产综合久久久久久久久久久久| 亚洲欧美激情视频在线观看一区二区三区 | 另类小说欧美激情| 亚洲欧美日韩在线| 欧美v日韩v国产v| 色先锋久久av资源部| 久久国产乱子精品免费女| 亚洲激情六月丁香| 久久久久久久久久久久电影 | 日韩午夜在线观看| 91天堂素人约啪| 黑人精品欧美一区二区蜜桃| 一片黄亚洲嫩模| 久久综合狠狠综合久久激情| 欧美三级电影网| 国产一区亚洲一区| 一区二区三区中文字幕精品精品| 欧美精品久久久久久久多人混战| av在线免费不卡| 精品亚洲aⅴ乱码一区二区三区| 一区二区三区在线播| 久久精品亚洲精品国产欧美| 欧美日韩电影一区| 色一区在线观看| 东方aⅴ免费观看久久av| 日本欧美一区二区三区乱码| 亚洲人成网站在线| 国产欧美日韩三区| 精品国产不卡一区二区三区| 欧美精品一级二级| 91麻豆精品在线观看| 东方欧美亚洲色图在线| 精品一区二区三区免费| 午夜视频一区二区| 亚洲精品第1页| 国产精品久久久久一区二区三区| 精品久久久久久久久久久久包黑料| 欧美视频在线一区| 色成年激情久久综合| 成人av中文字幕| 国产黄人亚洲片| 国内精品视频666| 青青国产91久久久久久| 午夜久久久久久电影| 一个色妞综合视频在线观看| 中文字幕一区二区三区乱码在线| 久久理论电影网| 亚洲精品在线免费观看视频| 91麻豆精品国产91久久久资源速度 | 国产福利一区二区三区视频| 中文字幕精品三区| 精品欧美一区二区在线观看| 制服丝袜一区二区三区| 欧美日韩国产一级| 欧美日韩大陆一区二区| 欧美日韩精品久久久| 欧美日韩一区二区三区高清| 色婷婷综合久久久久中文一区二区| 99久久伊人精品| 99久久精品一区二区| 色综合天天性综合| 91麻豆蜜桃一区二区三区| 一本大道久久a久久综合婷婷| 99久久久无码国产精品| 一本色道a无线码一区v| 日本高清免费不卡视频| 91官网在线观看| 欧美日韩一区二区三区视频| 8x福利精品第一导航| 欧美一二三四区在线| 日韩一级黄色大片| 精品国产91亚洲一区二区三区婷婷| 精品免费视频一区二区| 久久久九九九九| 国产精品女主播在线观看| 亚洲欧美电影院| 亚洲夂夂婷婷色拍ww47 | 天天色综合天天| 麻豆国产精品777777在线| 黄页网站大全一区二区| 国产精品系列在线观看| 麻豆专区一区二区三区四区五区| 国产成人av福利| 丰满亚洲少妇av| 91在线精品一区二区| 欧美在线视频你懂得| 91麻豆精品国产自产在线| 26uuu亚洲综合色欧美| 国产欧美日韩激情| 亚洲欧美日韩久久精品| 亚洲 欧美综合在线网络| 精品在线你懂的| 成人影视亚洲图片在线| 色婷婷国产精品| 这里只有精品视频在线观看| 久久久综合视频| 亚洲欧美偷拍三级| 午夜欧美电影在线观看| 黄色小说综合网站| 91色综合久久久久婷婷| 制服丝袜在线91| 欧美激情中文字幕一区二区| 亚洲综合一区二区三区| 久久精品久久99精品久久| 成人夜色视频网站在线观看| 色老头久久综合| 日韩精品一区二区三区在线观看 | 99久久国产综合色|国产精品| 91久久一区二区| 精品国产乱码久久久久久图片| 中文av字幕一区| 丝袜国产日韩另类美女| 岛国一区二区在线观看| 欧美日韩国产一级| 久久久精品免费网站| 亚洲国产三级在线| 国产一区二区导航在线播放| 色老汉一区二区三区| 色诱视频网站一区| 91精品国产丝袜白色高跟鞋| 麻豆精品在线看| 成人av在线网站| 91精品午夜视频| 国产精品剧情在线亚洲| 日韩精品电影在线| 91在线免费视频观看| 亚洲成人av福利| 国产精品一区二区果冻传媒| 精品视频全国免费看| 国产精品午夜免费| 久久99久久精品| 欧美日韩中文字幕精品|