最适合初学者的简单JAVAWEB项目快速入门(A quick start to a simple JavaWeb project most suitable for beginners)
3.下载eclipse javaee版，方便开发web项目（注意：eclipse javase版也可以，但需要下载插件。另外开发工具有许多，不一定非要eclipse，我只是举例）。另外，一定要注意：ee版选择动态web项目后，Tomcat等是配置好的，不需要再配置，再配置也会报端口号占用的错误！
Recently, I have studied Java Web for some time, but I can’t do it as a project. I believe many beginners have the same problem as me, that is, why do I learn, but I can’t do it? And how to do a simple web project? For beginners, I think it is most appropriate to answer this question from the perspective of me, a beginner. Here are my thoughts:
The results of my own reflection are as follows,
Why can’t you do a project after learning:
1、 Lack of understanding of the technology to be learned leads to learning a little, learning a little, and finally doing a lot of useless work and not being proficient at anything
2、 I won’t apply the learned technology. For example, I learned SQL statements, and I don’t know which part of the code to write
3、 The learning contents are not linked together. For example, I can connect to the database through JDBC, learn servlet, and read JSP, but I can’t connect them.
At the same time, I also gave the solution:
For the first and second points, I have summarized the technology, purpose and degree of being a Web:
First, the installation and configuration of the environment,
1. Download the database and database visualization interface software. The visualization interface software is to facilitate the creation of tables before connecting to the database. Learning SQL statements is to write in the code to realize the operation of adding, deleting, modifying and querying. For example, the database I studied is mysql, and the visual interface software I used is sqlyog. Note: remember to download the driver when downloading the database. In the future, you don’t have to download the driver when connecting to the database through JDBC!
2. Download the server Tomcat. Using Tomcat can make your page run in the browser.
3. Download eclipse Java EE version, easy to develop web projects (Note: eclipse) Java SE version is OK, but you need to download plug-ins. In addition, there are many development tools, not necessarily eclipse. I’m just giving an example). In addition, it must be noted that after the dynamic web project is selected in the EE version, Tomcat and others are configured. There is no need to reconfigure, and the port number occupation error will be reported in the reconfiguration!
After downloading, you should know how to use the configuration. When learning SQL database, you will learn that Tomcat can search online for how to configure and eclipse can search online for how to establish dynamic web projects.
Second, learn Java. JavaWeb must know java code. In fact, servlets are Java classes, and their own data should be encapsulated. In short, there are too many places to use Java. At least three structures, methods, arrays, strings, classes and objects, and exceptions, such as sequence, selection, and loop, shall be met.
The third is the use of database. We should learn the operation of database SQL statement and database visual interface. The purpose has been mentioned at the time of download. Need to be able to skillfully operate the database with SQL statements, and can skillfully operate the database with visual interface software.
Fourth, JDBC connects to the database. The purpose of learning here is to know how to connect to the database. In terms of the operation of adding, deleting, modifying and querying in the future, connect to the database to add, delete, modify and query. You need to know and be proficient in using JDBC APIs, namely drivermanager, Preparedstatement, connection and resultset.
Fifth, the design of the front page. There are many choices here. If you are anxious to go through the web process, you can choose one to learn first, such as HTML, JSP, etc. Need to be able to design the front page and understand other people’s templates.
The sixth is to learn servlet, which is to accept the commands from the front end and call the back-end methods to perform the operations required by the front end. Learning servlet requires skillfully rewriting doget and dopost methods to achieve our goal.
The other is question 3. I have learned all the knowledge, but how can I string it together? In fact, after learning all the above contents, I still can’t do the project, that is, the knowledge I learned is not connected. I think there are two reasons for not connecting them. First, I don’t know what to do after learning, but this problem has been solved above. Second, there is no project, only theoretical basis, no practical operation. This is the best question. What should I do? Practice!
Of course, it’s easier said than done. I think this is the hardest step. When doing a project, we should think about where to start, whether it is front-end to back-end or back-end to front-end, and so on. There are many implementation methods. And how to layer, how to build classes and packages… Of course, beginners can think first. When they do more, they will figure it out. The most important thing now is to start practicing and do a small web project. So, this jumps to the second question, how to do a simple web project.
And how to do a simple web project:
First of all, I think the most important thing is layering. You should know that the bean / Dao / service / servlet layer is established in that file, the driver package is stored in that file, and the front-end page is placed in that file. I think these problems are the so-called string. I learned from the video of station B. This is the video I learned: https://www.bilibili.com/video/BV18s411u7EH?p=23 In sections 23 and 24, we talked about MVC mode and three-tier architecture respectively, and we have done projects with them. I think we can follow them if we haven’t done so. Of course, you don’t have to watch videos. You can also search other people’s projects online, such as student management system, census system, etc. I recommend those projects with directories, so that you can better understand how to layer. When I study, I not only watch videos, but also watch other people’s projects. The advantage of watching other people’s projects is that they can be copied and can quickly understand layering, but I ignore the specific details of internal code. And basically there is no detailed description of layering. Most of them are code. Do you like to see it. After watching the video, I was deeply impressed by the layering, and I knocked it myself, so I know more about the details. But the video can’t be copied. You can only knock it yourself. Before you knock it out, you may not have a thorough understanding of the large framework. Then I will publish my code and directory. You can have a look and think again.
The second is the internal details of the code. As long as you learn well, there is generally no problem here.
The above just talks about the general framework. To do a good job in a project, you should have a good understanding of each technology. You can’t just try to be fast. When I say what SQL statements to learn, you can directly see what SQL statements I say, how to build tables, etc., but in fact, you don’t know what the database is. This behavior must not work. Moreover, in the process of practice, we will certainly encounter various bugs, such as Tomcat report 404, page garbled code and so on. These need to be solved by our own search, which is not mentioned above but very important. Of course, I am just a beginner. If there is anything wrong with my understanding, you are welcome to discuss it.
Finally, I would like to encourage you to make a complete web project as soon as possible!