亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

Struts2 Key Technologies Primer

2019-11-10 17:17:21
字體:
來源:轉載
供稿:網友

“The time has come,” the Walrus said, “To talk of many things: Of shoes – and ships – and sealing-wax – Of cabbages – and kings – And why the sea is boiling hot – And whether pigs have wings.”

Intention

If you would like to get started with Apache Struts you most likely want to know what technologies you need to learn. This document shall give you a brief overview what you need to successfully run a Struts PRoject.

If you still can’t decide if Struts is for you or if you have any questions, feel free to contact us via the Struts user mailinglist.

Key Technologies

 

What you need to know

The framework documentation is written for active web developers and assumes a working knowledge about how java web applications are built. Before getting started, you should understand the basics of several key technologies:

HTTP and HTMLThe HTTP Request/Response CycleThe Java Language and Application FrameworksJavascript, Ajax, and SOAPProperties Files and ResourceBundlesServlets, Filters and Web ContainersJavaServer Pages and jsp Tag LibrariesExtensible Markup Language (xml)JAASModel View Controller

This primer briefly defines each of these technologies but does not describe them in detail. For your convenience, links to further information are often provided where it makes sense.

General starting points

If you are not familiar with the Java language generally,then the best starting point is the Java Tutorial.

If you are familiar with Java, but not the mentioned technologies, the best overall starting point is the Java EE Tutorial.

If you’ve created web applications for other platforms, you may be able to follow along and visit the other references as needed. The core technologies used by Struts are also used by most other Java web development products, so the background information will be useful in any Java project.

HTTP, HTML and User Agents

The World Wide Web was built over the Hypertext Transfer Protocol (HTTP) and the Hypertext Markup Language (HTML). A User Agent, like a web browser, uses HTTP to request a HTML document. The browser then formats and displays the document to its user. HTTP is used to transport more the HTML, HTML from the browser to render the view.

If you would like to learn HTML, we recommend Getting started with HTML by Dave Raggett.

The HTTP Request/Response cycle

A very important part of HTTP for the web developer is the request/response cycle. To use HTTP you have to make a request. A HTTP server, like a web server, is then obliged to respond. When you build your web application, you design it to react to a HTTP request by returning a HTTP response. Frameworks often abstract much of these nuts and bolts, but it is important to understand what is happening behind the scenes.

If you are not familiar with the HTTP request/response you should learn about it. There is a lot of help available in the internet, like How does the Internet work?

The Java Language and Application Frameworks

Struts is written in the Java programming language. Java is an object-orientated language, and the framework makes good use of many object-orientated techniques. A good understanding of Java, and especially object-orientated programming (OOP) and threading, will help you get the most out of Struts.

Reflection and Introspection

Reflection is the process of determining which member fields and methods are available on an object. Introspection is a specialized form of reflection used by the JavaBean API. Using Introspection, we can determine which methods of a Object are intended to be accessed by other objects. The getters and the setters, for example.

Struts uses Introspection to convert HTTP parameters into JavaBean properties and to populate HTML fields from JavaBean properties. This technique makes it easy to “roundtrip” properties between HTML forms and JavaBeans.

While it is not necessary to have a deep understanding of these concepts when you start with Apache Struts, it will help you when your application grows and becomes more complex.

Properties Files and ResourceBundles

Java applications, including web applications, are often configured using Properties files. Properties files are the basis for the ResourceBundles that the framework uses to provide message resources to an application.

The Java Tutorials provide a great introduction to Properties.

Java ResourceBundles use one or more Properties files to provide internationalized messages to users based their Locale. Support for localizing an application was built into the framework from the ground-up.

Again the Java Tutorials provide more information.

Threads

With Struts 1 you were required to know a lot about how to write code which can run in a multi-threaded environment. With Struts 2 this is no longer necessary. In an Struts 2 environment each action caused by a HTTP request is a plain old Java object which is instanced for each request.

JavaScript, AJAX, and SOAP

WIth HTTP and HTML you can already provide static web pages. Today this is much often not longer enough and your application users might expect a interactive user interface. Web developers often resort to JavaScript to make web applications more interesting.

AJAX is a technology often used by JavaScript programmers to create web applications that are as interactive and responsive as desktop applications. It is possible, to load a view parts of the website or just the data from the (Struts) application instead of regenerating the whole view.

Apache Struts provides plugins to easily work with AJAX and even JavaScript. Where Struts can’t provide the necessary functionality, third parties provide extensions for the required behavior.

Another technology that can enhance the HTTP request/response cycle is SOAP. Using SOAP, an application can access data and invoke business logic on another server using HTTP as transfer layer. Using AJAX and SOAP together is becoming a popular way for page to submit finely-grained requests directly to a remote server, while still retaining a separation of concerns between the the business logic and the page markup. Depending on your applications need, it might be not necessary for you to learn about SOAP.

Servlets, Filters, and Web Containers

Since Java is an object-orientated language, the Java Servlet platform strives to cast HTTP into an object-orientated form. This strategy makes it easier for Java developers to concentrate on what they need their application to do – rather than the mechanics of HTTP.

A Java-aware HTTP server can pass a request to a servlet container. The container can fulfill the request or it can pass the request back to the HTTP server. The container decides whether it can handle the request by checking its list of servlets. If there is a servlet registered for the request, the container passes the request to the servlet.

When a request comes in, the container checks to see if there is a servlet registered for that request. If there is a match, the request is given to the servlet. If not, the request is returned to the HTTP server.

It’s the container’s job to manages the servlet lifecycle. The container creates the servlets, invokes the servlets, and ultimately disposes the servlets.

The old Struts 1 version relied heavily on servlets and good knowledge about it usually helped a lot with developing web applications.

With Struts 2, you’ll need only a basic understanding of Servlets. Struts actually uses a so called ServletFilter to "make things work". In general you are not required to write Servlets when using Struts 2. It still helps to know what Servlets, Filters and Containers are.

Filters let you compose a set of components that will process a request or response. Filters are aggregated into a chain in which each filter has a chance to process the request and response before and after it is processed by subsequent filters (and the servlet that is ultimately called).

sessions

One of the key characteristics of HTTP is that it is stateless. In other Words, there is nothing built in to HTTP that identifies a subsequent request from the same user as being related to a previous request from that user. This makes building an application that wants to engage in a conversation with the user over several requests to be somewhat difficult.

To alleviate this difficulty, the servlet API provides a programmatic concept called a session, represented as an object that implements thejavax.servlet.http.HttpSession interface. The servlet container will use one of two techniques (cookies or URL rewriting) to ensure that the next request from the same user will include the session id for this session, so that state information saved in the session can be associated with multiple requests. This state information is stored in session attributes (in JSP, they are known as “session scope beans”).

To avoid occupying resources indefinitely when a user fails to complete an interaction, sessions have a configurable timeout interval. If the time gap between two requests exceeds this interval, the session will be timed out, and all session attributes removed. You define a default session timeout in your web application deployment descriptor.

It is important to know that Session data most often occupies RAM memory of your server. Depending on your container you may have different options to bypass this.

Struts 2 provides easy ways to create and access a session.

Web Applications

Just as a HTTP server can be used to host several distinct websites, a servlet container can be used to host more than one web application. The Java servlet platform provides a well-defined mechanism for organizing and deploying web applications. Each application runs in its own namespace so that they can be developed and deployed separately. A web application can be assembled into a Web Application Archive, or WAR file. The single WAR can be uploaded to the server and automatically deployed.

You definitely need to learn how you can build a war file from your Struts application and deploy it to your server. This might require knowledge of build tools like Maven and addition reading in the documentation of your server vendor.

Security

One detail that can be configured in the Web application deployment descriptor is container-managed security. Declarative security can be used to protect requests for URIs that match given patterns. Pragmatic security can be used to fine-tune security make authorization decisions based on the time of day, the parameters of a call, or the internal state of a Web component. It can also be used to restrict authentication based on information in a database.

For more about security, you should read the Java EE tutorial. Other projects, like Apache Shiro or Spring Security might also help you to secure your web application.

JavaServer Pages, JSP Tag Libraries, and JavaServer Faces

If you write a classic web app, you might need a view component. One of the first of its kind was JSP.

While still powerful and fully supported by Struts, people might prefer other technologies like Velocity and Freemarker. Both are also first class citizens for Struts.

All have in common that you would start writing HTML markup and add dynamic features using JSP tags (same goes for Velocity and Freemarker). While it is not recommended, JSP even supports adding plain Java to the markup. Reading about the JSTL or, even better, the Unified expression language is recommended.

That said, you can easily access your data model from the view. And render it appropriate. If you would like to use a more modern approach, you will love to hear Struts 2 provides features to return JSON, which usually fuels AJAX driven webpages. With that it is easily possible to use jQuery orAngularJS as a front end layer and even completely discard JSP.

As mentioned, aside from Java Server Pages, there are several other presentation technologies available to Struts:

FreemarkeriText (PDF)JasperReportsVelocityXSLT

Extensible Markup Language (XML)

The features provided by the framework rely on a number of objects that are sometimes deployed using a configuration file written in Extensible Markup Language. XML is also used to configure Java web applications; so, this is yet another familiar approach.

Luckily Struts 2 reduces the need for XML to almost zero. While a basic knowledge on XML is always good, it is no longer crucial to write long XML documents to create a Struts application. If you would like to read more about it, please visit the page of the Convention plugin.

Model View Controller (MVC)

Web applications based on JavaServer Pages sometimes commingle database code, page design code, and control flow code. In practice, we find that unless these concerns are separated, larger applications become difficult to maintain.

One way to separate concerns in a software application is to use a Model-View-Controller (MVC) architecture. The Model represents the business or database code, the View represents the page design code, and the Controller represents the navigational code.

The term “MVC” originated with the SmallTalk Model-View-Controller framework. In Smalltalk MVC, the View updates itself from the Model, via the “Observer” pattern. The original MVC pattern is like a closed loop: The View talks to the Controller, which talks to the Model, which talks to the View.

But, a direct link between the Model and the View is not practical for web applications, and we modify the classic MVC arrangement so that it would look less like a loop and more like a horseshoe with the controller in the middle.

In the MVC/Model 2 design pattern, application flow is mediated by a central Controller. The Controller delegates requests - in our case, HTTP requests - to an appropriate handler. The handlers are tied to a Model, and each handler acts as an adapter between the request and the Model. The Model represents, or encapsulates, an application’s business logic or state. Control is usually then forwarded back through the Controller to the appropriate View. The forwarding can be determined by consulting a set of mappings, usually loaded from a database or configuration file. This provides a loose coupling between the View and Model, which can make applications significantly easier to create and maintain.

While MVC is a convenient paradigm, many workers find that applcations may utilize more than three layers. For example, within the Model, there is often distinct business logic and data access layers.

The framework provides the control layer for a Model 2 web applications. Developers can use this layer with other standard technologies to build the business, data access, and presentation layers.

For more about MVC, see

Smalltalk MVC framework.Wikipedia - MVC

Business Logic Frameworks

Most teams still roll their own business logic layer using plain old JavaBeans (POJOs). Though, business layer frameworks are beginning to emerge, and now include:

SpringGoogle GuiceCommons Chain of Responsiblityor you can rely on features of the bundled Struts XWork

Data Access Frameworks

Most often, the business layer is seen to be distinct from the data access layer. Some teams roll their own data access objects (DAOs), but more and more teams are turning to one of the many data access frameworks. Some popular data access frameworks include:

Apache CayenneEnterprise Java BeansHibernatemyBATIS
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
欧美黄色片免费观看| 狠狠久久五月精品中文字幕| 日韩精品视频在线观看免费| 欧美黑人一级爽快片淫片高清| 色婷婷综合久久久久中文字幕1| 中文综合在线观看| 国产精品久久久久久av福利软件| 亚洲图中文字幕| 欧美日本黄视频| zzijzzij亚洲日本成熟少妇| 亚洲欧美日韩直播| 深夜福利一区二区| 精品国产户外野外| 免费99精品国产自在在线| 欧美亚州一区二区三区| 久久亚洲精品中文字幕冲田杏梨| 亚洲午夜精品久久久久久性色| 懂色av一区二区三区| 国产一区视频在线播放| 欧美午夜性色大片在线观看| 欧美激情视频在线| 国产精品aaa| 狠狠做深爱婷婷久久综合一区| 68精品国产免费久久久久久婷婷| 精品国产91乱高清在线观看| 亚洲欧美在线免费| 精品国产乱码久久久久久婷婷| 成人欧美一区二区三区在线湿哒哒| 久久久国产精品一区| 亚洲精品一区中文字幕乱码| 色视频www在线播放国产成人| 亚洲欧美另类国产| 91亚洲国产成人精品性色| 97人人爽人人喊人人模波多| 日本午夜精品理论片a级appf发布| 日韩电视剧免费观看网站| 91人人爽人人爽人人精88v| 亚洲成人aaa| 日韩精品视频在线观看网址| 久久精品电影一区二区| 欧美午夜丰满在线18影院| 国产999视频| 操91在线视频| 夜夜嗨av色一区二区不卡| 日韩av一区二区在线| 欧美精品18videos性欧美| 欧美午夜片欧美片在线观看| 中文字幕精品www乱入免费视频| 国产原创欧美精品| www.欧美三级电影.com| 激情av一区二区| 1769国内精品视频在线播放| 欧美成人精品不卡视频在线观看| 国产精品色婷婷视频| 欧美高清自拍一区| 92版电视剧仙鹤神针在线观看| 国产精品国产自产拍高清av水多| 自拍亚洲一区欧美另类| 欧美肥婆姓交大片| 亚洲国产精品专区久久| 中文字幕日韩专区| 亚洲精品av在线| 亚洲美女在线观看| 久久精品视频免费播放| 日韩高清电影免费观看完整| 亚洲老板91色精品久久| 国产精品美女999| 久久免费高清视频| 红桃视频成人在线观看| 欧美激情视频免费观看| 欧美大片va欧美在线播放| 亚洲欧美日韩爽爽影院| 欧美夫妻性视频| 亚洲伊人一本大道中文字幕| 狠狠做深爱婷婷久久综合一区| 欧洲一区二区视频| 久久香蕉国产线看观看av| 成人午夜激情免费视频| 亚洲成年网站在线观看| 亚洲成年人在线播放| 亚洲精品小视频在线观看| 久久人人爽人人爽人人片av高请| 午夜精品一区二区三区视频免费看| 亚洲一区中文字幕在线观看| 成人激情黄色网| 欧美国产高跟鞋裸体秀xxxhd| 国产丝袜一区二区三区| 精品国产老师黑色丝袜高跟鞋| 亚洲欧美制服中文字幕| 亚洲美女中文字幕| 久久99久久99精品免观看粉嫩| 国产日韩在线一区| 2019亚洲男人天堂| 成人欧美一区二区三区在线湿哒哒| 黄色一区二区三区| 欧美午夜激情在线| 国产精品久久久久久久久久久久| 不卡av电影在线观看| 在线观看国产精品淫| 国产精品视频资源| 亚洲国产日韩欧美在线图片| 中文字幕精品www乱入免费视频| 日韩专区在线播放| 久久久久久综合网天天| 91国产精品91| 国产丝袜一区二区三区免费视频| 欧美性猛交xxxx黑人| 美女福利视频一区| 欧美国产日韩视频| 亚洲成人免费在线视频| 日韩精品在线免费观看| 久久久精品国产亚洲| 亚洲欧美制服中文字幕| 国产精品高清免费在线观看| 日韩在线观看免费全集电视剧网站| 亚洲人午夜精品免费| 亚洲精品动漫久久久久| 国产精品高清在线观看| 日韩中文字幕不卡视频| 亚洲欧美福利视频| 自拍偷拍免费精品| 亚洲男人天堂2024| 国产精品自产拍在线观| 亚洲网在线观看| 亚洲高清久久久久久| 国产精品女人久久久久久| 亚洲一区二区三区四区视频| 久久久免费精品| 操人视频在线观看欧美| 成人自拍性视频| 成人两性免费视频| 欧美一区二区三区图| 亚洲乱亚洲乱妇无码| 国产在线精品一区免费香蕉| 精品国产一区二区三区久久久| 久久精品最新地址| 亚洲福利视频网站| 日韩av日韩在线观看| 欧美高清视频在线| 国产日韩av高清| 亚洲成年人影院在线| 97久久伊人激情网| 91久久久精品| 亚洲男人天天操| 欧美日韩国产成人| 亚洲欧洲激情在线| 青草成人免费视频| 国产做受高潮69| 亚洲欧美日韩在线高清直播| 国产精品va在线| 97香蕉超级碰碰久久免费的优势| 成人激情黄色网| 国产999视频| 毛片精品免费在线观看| 亚洲精品免费在线视频| 欧美国产第二页| 亚洲人成电影网站色xx| 亚洲第一在线视频| 国产精品国产亚洲伊人久久| 最近2019中文字幕在线高清| 亚洲精品成人av| 97香蕉久久夜色精品国产| 国内精品模特av私拍在线观看| 中文字幕在线观看日韩|