Struts and MVC mode

zhaozj2021-02-16  83

Struts framework:

One open source project of Jakarta is the implementation of the web-based MVC framework. It is ideal for developing large-scale web programs Struts to implement the Controller's function. You can control the flow between the page rooms to control the flow in the View layer. Make us reduced the amount of code in the page with simple tag, and even don't have code in the JSP page in the Model layer, Struts provides an action, to handle requests from JSP, and the wrong processing, we can more Time spending Struts is a Model-View-Controller implementation using servlet and JavaServer Pages technology. Struts helps you control changes in the web project and improve the level of specialization. Although you may never use Struts to implement a system, you can use some of these ideas for your future servlet and JSP webpage implementation.

Model - View - Controller (MVC) JSP tag only solves some problems. We have to handle issues such as verification, process control, and update applications. This is where the MVC works. MVC helps solve some of the problems encountered by the single module method by dividing the problem into three categories:

The Model model contains the core function of the application. The model encapsulates the status of the application. Sometimes the only function it contains is status. It doesn't know anything about the view or controller. View view provides a representation of the model. It is the appearance of the application. The view can access the model's read method, but the write method cannot be accessed. In addition, it doesn't know anything about the controller. The view should be notified when changing the model. The Controller controller responds to the user's input. It creates and sets the model.

"Model - View - Controller" (MVC); is a design pattern used to help you control changes. The MVC weakens the coupling between the business logic interface and the data interface. Struts is an MVC implementation that uses Servlet 2.2 and JSP 1.1 tags (belonging to J2EE specification) as part of the implementation. Although you may never use Struts to implement a system, you know that Struts may allow you to use some of the ideas for the JSP implementation of your later servlet.

Struts overview

CLIENT BROWSER Creates an event from each HTTP request from the client browser. The Web container will respond with an HTTP response. The Controller controller receives a request from the browser and decides where to send this request. For Struts, the controller is a command design pattern implemented by a servlet. Struts-config.xml file configuration controller. Business logic logic updates the status of the model and helps control the flow of applications. For Struts, this is done by the Action class "thin" packaging as the actual business logic. The status model of the Model represents the status of the application. Business object updates the status of the application. The ActionForm bean represents the status of the model in the session stage or the request grade, not in the persistence. JSP files read information from Actionform Bean using JSP tags. View view is a JSP file. There is no process logic, no business logic, and there is no model information - only the tag. The tag is one of the factors that make Struts different from other frameworks (such as Velocity).

Struts Advantages

The use tag feature of the JSP tag mechanism is a reusable code and abstract Java code from the JSP file. This feature is well integrated into JSP-based development tools, which allows you to write code with tags. Why should the tag library have an inventive wheel or a tag library? If you can't find the tag you want in the library, then you will define it. Also, if you are learning JSP tag technology, Struts provides you with a starting point. Open source You can get all the advantages of open source, such as you can view the code and check each person of the library to check the code. Many people can check very well. MVC implementation If you want to create your own MVC implementation, Struts can increase your knowledge. Management problem spatial rules are excellent ways to solve problems and make problems manageable. Of course, this is a double-edged sword. The problem is getting more complicated, and more and more management is needed. Struts Disadvantages

The development of Struts is still in the initial stage. They are working hard to the release version 1.0, but as with any 1.0 versions, it is impossible to do it. This frame is still changing in a variety of changes. Struts 1.0 varies greatly compared to Struts 0.5. In order to avoid the use of the method that does not agree, you may need to download the latest Struts over one day. In the past 6 months, I witnessed the Struts library increased from 90k to 270K. Due to changes in Struts, I have to modify my example several times, but I don't guarantee that my example works with Struts you downloaded. Does the correct abstraction level Struts provide the correct abstraction level? What is the correct abstraction level for web designers? This is a problem with the text with $ 64K. In the development of a web page, should we let the web designers visited the Java code? Some frameworks (such as velocity) should not, but it provides another web development language to make us learn. Restrict access Java in UI development has certain rationality. Most importantly, if web designers use a little Java, he will use a lot of Java. In the development of Microsoft ASP, I always see this situation. In ASP development, you should create a COM object, then write a small amount of ASP scripts to link these COM objects. However, ASP developers will use ASP scripts crazy. I will hear this, "Since I can write COM objects with VBScript, why should I wait for COM developers to create it?" By using the tag library, Struts helps limit the Java code required in the JSP file. Quantity. Logic Tag is a library that manages conditionally generated output, but this does not prevent UI developers from fanatizing the Java code. Whether you decide which type of framework you want to use, you should know the environment you want to deploy and maintain the framework. Of course, this task is really difficult to do. Limited Scope Struts is a web-based MVC solution that must be implemented with HTML, JSP files, and servlets. The J2EE application supports Struts that requires Servlet containers that support JSP 1.1 and Servlet 2.2 specification. This is far from which you can solve all your installation issues unless Tomcat 3.2 is used. I am installing this library with Netscape Iplanet 6.0, I encountered a lot of problems, and it is the first application server that meets J2EE. I recommend that you access the archive of the Struts user mailing list when you encounter problems (see Online Resources). The complexity is also introduced into several parts of several parts. There is no doubt that you must understand that struts must accept certain training. As the changes continue to join, this is sometimes very frustrating. Welcome to this website. Where can I still point out other issues, for example, where the controller's client verification, how can the workflow and dynamic policy mode? However, this is now too easy to become a problem of phenomenon, some problems are irrelevant, or these issues should be issued for 1.0 issues. With the continuous efforts of the Struts team, Struts may have these features when you read this article, or it will have these features soon.

Struts's prospects in this new era development, everything has become very fast. In less than five years, I have witnessed from CGI / Perl to ISAPI / NSAPI, and then use VB's ASP, until the current Change of Java and J2EE. Sun is trying to reflect new changes to the JSP / Servlet architecture, as they are the same as the change made by the Java language and the API. You can get a new draft of JSP 1.2 and Servlet 2.3 specification from Sun's website. In addition, a standard JSP tag library will appear; for links to these specifications and tag libraries, see the online resource. The final comment Struts uses tags and MVC to solve certain major problems. This method helps to increase the reusability and flexibility of the code. By dividing problems into smaller components, you have more opportunity to reuse code when there is a change in technical space or problem space. In addition, Struts enables web designers and Java developers to focus on their best aspects. However, while strongness is enhanced, it also means complexity increases. Struts is much more complicated than a simple single JSP page, but for larger systems, Struts actually helps manage complexity. In addition, I don't want to write my own MVC implementation, but I just want to know a such implementation. Whether you will use Struts, review this Struts framework (sorry, it should be library) will make you a better understanding of the JSP file and servlet, and how to combine them for your next Web project. The positive image wing pillar is an indispensable part of the wing structure, and Strut may become an indispensable part of your next web project.

转载请注明原文地址:https://www.9cbs.com/read-13587.html

New Post(0)