In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to manually configure Java tomcat servlet, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Preparatory work
As shown in the following figure, first create each file as required
If you think it can work at this time, you are wrong (I was stuck here in the first place)
Project structure of idea
If you have learned to create servlet applications with idea, you will surely find that the web.xml provided here is not complete at all
Please include the above servlet tag with the following code
/ / add the servlet tag code mentioned above 2. There is a problem with the coding of the compiled file.
As above, I tried to compile at first, but I reported it wrong.
The reason here is that javac will read the source code according to your operating system code, while my computer defaults to GBK, but we write all these source codes in notepad, and notepad is saved using UTF-8 by default, so it is equivalent to javac reading the contents of UTF-8 with GBK and reporting an error.
Therefore, we want to specify that the encoding format of the read source code is UTF-8
Learning class loader
At this time, the error reported is normally displayed in Chinese, and the servlet cannot be found, which means you used this class, but did not find it. According to the parents' delegation, we know that to find a class, we will start looking for the cache of the system class loader class loader. If not, we will find its parent loader, that is, the cache of extension class loader. If not, we will find the cache of extension class loader's parent loader, bootstrap class loader, or we will start to go down without it. First find out whether the jar package under the specified path of bootstrap class loader contains the classes we want. As you can see from the following figure, load the core jar package with the class loader. Some basic classes are in it. The path is lib under jre under jdk.
At this time, I can't find it yet, so I go to extend the specified path of the classloader. My computer is the following path.
If you haven't found it yet, use the path specified by the system class loader, that is, the familiar classpath, which you should have encountered when configuring path.
So, the-cp command followed by classpath tells the system to go to me if one is not found.-the full name of cp is-classpath can work.
Processing compilation results
When you javac by typing cmd in the file manager, the class file is generated by default in the current directory, but there is an important point here. The java source file you wrote has the command package, so we must create a folder step by step according to the package name (you can only find the self-written source file you imported at run time).
-d is where the class is placed,-d. It is very convenient to help us create package folders automatically under the current directory without having to create them manually.
The above is all the contents of the article "how to configure servlet manually by Java tomcat". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.