When I contact Struts2, there is even no concept for web development, the only knowledge is how to use HTML, CSS and simple js to write static Web pages. There is no basic understanding of the background and database necessary to develop a Web site.
Therefore, this blog post, can be said not only the author use struts2 framework for Web development experience summary, but also so far a simple comb web development.
As a beginner, continuous search has become a vital part of the development process without the systematic learning of computer networks and any practical experience in the Web. Therefore, this article on the basis of the report experience and learning context, will list out an article to help me, will be based on STRUTS2 Web development encountered a series of details to reproduce, hope for struts2 and web development for beginners to provide some reference.
First, the basic process of web development
In my understanding, Web development based on STRUTS2 is actually the same as its operating mechanism, and it is very simple:
Front End (Web page)--------(incoming user input)-------->
Background (Java-Written action Class)----(in response to input made by the user in the Web page, store the necessary data in the database)---->
Database (usually in the form of a table in a MySQL database)------(return the data needed for the response)-------------->
Background (the same as the previous Java-written action Class)---(processing data returned from the database, processed to the front page, displayed to the user)----->
Front end (may be the same page, or it may be different, the content displayed is related to the user's previous input).
The above language is better understood, probably only in the background "Java Write action class" puzzling. The so-called action class is the "brain" of the STRUTS2 framework that handles front-end Web pages and databases, and is the core of our website's ability to handle a range of businesses. Usually a website will have different action classes to handle different requests/business. Its main function is to receive and process processing (usually to store new data in the database) from the front-end Web page data (user requests, input data waiting), and access to the database, take out the required data, according to business needs, return to the front page to display the required data. It is called the action class, one of which is a class written by Java code, and the other is the take action according to request from front end and respond with data in Datab ASE. (I hope the Chinese and English inclusions are not embarrassing ...) )
Yes, even superficial plain English, I believe you may not be able to see a word, but for the rookie like me before, the basic concept must be built up in advance, the mind has a frame, and then fill in the inside of things is much simpler. (In fact, struts2 itself is such a pits process)
Second, the MVC model
In the Web development process I introduced earlier, I have unconsciously divided the web framework into three parts: front end, background, and database, and connect them with entities: Web pages, Java code, and database data.
Behind this is the fact that there is such a well-known MVC model, M--model--java object, v--view--page--html/css/javascript,c--control--java control class.
There are a lot of introduction and introductory tutorials on the MVC model on the Internet, so that readers can search and read the relevant content, and think that it will deepen the readers ' understanding of the Web development process and make a preliminary impression.
RELATED links:
the design of MVC architecture from the MVC framework-code Farm www.codeceo.com/article/mvc-framework-mvc-design.html
Introduction to Servlet and JSP development tutorial | Day Yards Camp-Next generation technology learning Service platform https://course.tianmaying.com/servlet-and-jsp
Third, the front-end introduction
Front end in the first part, we correspond to the Web page, and in the second part of the MVC model, the View section corresponds. As the name implies, the Web page and its content that the user sees through the browser is the front end.
Learning the front-end, we need to master HTML, CSS and JavaScript three great artifacts.
In layman's terms, HTML tells the browser what content to display, in what format (such as size, location, and so on). Therefore, the HTML contains the text that needs to be displayed and the labels to mark the text formatting. In addition to text, HTML can be used in a series of tags to introduce images, video, audio and even drawing board and many other functions.
For more detailed information, please learn through the W3S website. The web site covers a whole set of learning materials for the development of the website and is a widely admired web learning site.
w3s http://www.w3school.com.cn/
HTML Series Tutorial www.w3school.com.cn/h.asp
Although HTML can specify the size and position of text, it is very limited in functionality. CSS then applies magic to the elements in the HTML so that it can show more styles and display them in front of the user with better results.
CSS Tutorial http://www.w3school.com.cn/css/index.asp
If your pages are static, then HTML and CSS are enough to make amazing pages. But a static, difficult to respond to user input of the page function is greatly compromised. JavaScript can manipulate HTML and CSS, change how they are presented, and achieve dynamic results.
JavaScript Tutorial http://www.w3school.com.cn/js/index.asp
Iv. Getting Started with Java
Java is a widely used object-oriented programming language with multi-platform portability, a full library, and a back-end language in the Struts framework.
The Java code used in the Struts framework has no special requirements, so this is not a special introduction to Java, if the reader does not understand the Java language, please search the relevant information to read. A concise Java starter Tutorial is recommended here, and readers with programming experience should be able to master basic Java programming requirements in two or three days.
Java Getting Started tutorial https://course.tianmaying.com/java-basic
V. Start your struts2 Hello world
Access to a new framework/software, configuration problems are often cumbersome, time-consuming, and sometimes need to be tested repeatedly to succeed. How do I display a helloworld on a webpage? The following two articles may be helpful to you. (If you encounter problems, please do not worry, StackOverflow, CSDN and the distribution of enthusiastic netizens will answer questions, use a good search engine is the success of the Fast channel)
get ready for Struts 2.0-Max on Java-blogjava www.blogjava.net/max/archive/2006/10/10/74353.html
build a simple struts2.0 Web project-joy_zhao988 's column-blog channel-csdn.net blog.csdn.net/joy_zhao988/article/details/8684283
VI. realization of a struts2 CRUD
The so-called CRUD is the abbreviation for Create, Remove, Update, Delete 4 English words, which means that our website is no longer just a static website that can display Hello World, but must be able to reflect the corresponding result on the webpage according to the user's operation.
CRUD operations are the data inside the database, so our site must be able to connect to the database. CRUD instructions are the user's request on the front page, so our background Java program will be useful, one action class will be based on the user input data, access to the database to retrieve data, processed after the results are stored back into the database, and return to the results we want users to see.
The author of another blog record how to achieve a crud function of the book Management system, with a large number of configuration and code, hoping to be helpful to the reader.
struts2 CRUD Starter Configuration-zhangnf-Blog Park http://www.cnblogs.com/zhangnf/p/struts2.html
Compared with the previous Hello World, a large number of technical details will gradually be exposed. The author believes that the most critical problem is the data transfer between the front page and the background Java class. Attach the link again:
method of action receive parameter in STRUTS2-Datauta-Blog Park www.cnblogs.com/bukudekong/archive/2012/03/29/2423064.html
struts2 parameters from action to JSP-saobchj-Blog Park www.cnblogs.com/saobchj/archive/2012/05/09/2491641.html
The second is how the JSP effectively displays the data. For an in-depth understanding of JSPs and the servlet behind Struts2, you can refer to the following tutorials:
Introduction to Servlet and JSP development tutorial | Day Yards Camp-Next generation technology learning Service platform https://course.tianmaying.com/servlet-and-jsp
This article also provides useful information on JSP display data:
Struts2 data Labels (iv) Three ways to assign S:param tags--iteye technology website wl-ldy.iteye.com/blog/860169
Of course, there will be a lot of technical problems arise, please readers with good books at hand and the search engine, self-sufficiency, and clothed.
Seven, struts advanced--interceptor
Some say interceptors are the core of the STRUTS2 framework, not fake. Interceptors provide an important means of exerting additional action between the front-end page and the background action class. One of the most typical examples is illegal landing browsing page detection:
prevent non-logged-on user Action-struts2 interceptor Simple Implementation--blog channel-csdn.net blog.csdn.net/zhutulang/article/details/38351629
The knowledge about STRUTS2 interceptors covers the whole struts2 of the work, and interested readers can consult their own materials for learning.
Eight, the web advanced
To be a good site, you can naturally take into account every aspect of the web's operational process. For example, a very pleasing front-end, will be more attractive to other people's eyes. Bootstrap is a very good front-end framework that provides front-end developers with many useful layouts, components, and plug-in support. Using bootstrap as the front-end frame, you can achieve a modern web site layout, the effect is very beautiful.
Bootstrap Chinese document http://v3.bootcss.com/
How to efficiently implement a dynamic response site? jquery is a JavaScript wrapper, known as writing less and doing more JavaScript. It's worth mentioning that jquery also encapsulates Ajax, enabling you to perform background action actions without refreshing a webpage, and to update the power of Web content. jquery is very easy to write and powerful, and highly recommended to learn.
jquery Tutorial http://www.w3school.com.cn/jquery/
using jquery to implement STRUTS2 AJAX features-programming Records-Blog channel-csdn.net blog.csdn.net/yongh701/article/details/44279635
Ix. Summary
Nearly three months of study, I from the Web small white Step into the white, during the driving force of my continuous learning, it is from the Internet spread throughout the rich experience of predecessors. For this reason, I have the idea to publish my own learning experience. So here, I would like to express my gratitude to the authors who have quoted me in this article.
Here is a GitHub project for the group web Developer to share with your readers.
Https://github.com/py100/project-staples
Struts Development Experience Summary