Java Issues - Resolving a jQuery import issue in JavaWeb

Problem Description

  When I was learning javaWeb today, when I learned jQuery, I encountered a problem, which is probably like this:

  I made a small case, mainly when implementing ajax asynchronous requests through jQuery, you need to import jquery-3.3.1.jsfiles. The compiler I used at the time was IDEA. Therefore, I create a javaWEB project, and then configure the corresponding tomcat and path. Created a new folder under the web jsfolder. And write the corresponding code in the front-end page of jQuery's ajax, then start the project, and after entering the path, an error occurs: the UnCaught ReferenceError: Require is not defined。details are as follows:

  Through Baidu , I found that I forgot to import the jQuery package on the front-end page, so I added the following code:

<script src="js/jquery-3.3.1.min.js"></script>

  So I ran the code and found that GET http://localhost:8080/statics/js/jquery-3.4.1.js net::ERR_ABORTED 404an error was reported. The details are as follows:

  Then I Baidu online, it turned out to be a problem with jQuery, so I did it according to the method introduced by weixin_45094098 , and it turned out good, I have to say that it is really amazing, I put I will share with you my solution.

problem solved

  After importing jquery-3.3.1.min.js, you need to click Filethe button, then click Invalidate Cache/Restart..., then click the Invalidate and Restartbutton, Idea will restart, and invalid files will be filtered out. The specific process is as follows:

  Then perform this step:

  then restart the project, or refresh the page.

  The background execution of this project is as follows:

Summarize

  When we are learning java, we will inevitably encounter some problems. When we encounter problems, don't worry, this is a good thing! It's good to solve it, just go to the Internet and search it, you must not be the first to encounter this problem, there will be many answers to help you. Of course, this is also a way for you to improve. After you solve it, you will be able to encounter similar problems in the future, and you will not be in a hurry. Of course, there are also many wrong answers on the Internet. You can't solve it according to its method at all, and it wastes a lot of time. Therefore, when you operate according to others, look at the corresponding comments to see if others have solved it according to his method. Use as appropriate. Don't follow other people's instructions as soon as you open the article, this will not only not solve your problem, but it is very likely that your program will crash directly. Come on, people who work hard every day will be the most handsome, there will be, come on, code yuan! ! ! The future can be expected! ! ! ! ! ! ! ! ! ! ! ! !

references

[1] .weixin_45094098
[2] .∫Sakura

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324270504&siteId=291194637