Why is the request always 404?

Source: Internet
Author: User
Why is IT information always 404 requests? This time we will talk about 404. In the background of the public account and in the QQ group, some people are asking the following questions:

I have deployed the application, and no abnormal output is displayed when the background is started. A request to Tomcat manager is acceptable. Why does the request always return 404 for the application?

Yes. Why?

Let's analyze the description of this problem.

1. After the application is deployed, no exception is output in the background.

2. the Tomcat manager application can send normal requests.

The preceding two steps can only indicate that Tomcat is started properly. At the same time, the manager application and the user's application are successfully deployed, but the requests to the manager are normal, and you cannot ensure that your application can also perform normal requests.

After all, what resources are in your application and there is no association with the manager, or even the address may be wrong when you request. In other words, you can see that the application is deployed in the webapps directory, but requests in the browser always return 404 without stopping.

The above question is the main analysis content of this article. First, let's take a look at the status code of the HTTP request 404, which is described in wikipedia as follows:

The HTTP Error 404 (Not Found) is a standard response code. In computer network communication, it indicates that the client can communicate with the server, but the server cannot find the resources requested by the client.

In Tomcat, 404 is returned in many cases.

As mentioned in the previous article, Tomcat contains two default servlets:

JspServlet and defaservlet servlet. (How does Tomcat respond to static resources ?)

When we randomly request a nonexistent resource in Tomcat, for example, the following two resources do not exist:

Http: // localhost: 8080/abc and http: // localhost: 8080/abcd. jsp

At this time, the requests will be sent to the two servlets mentioned above. At this time, because the resource does not exist, the returned 404 is consistent with our expectation.

At this time, every request would be 404, but you can see that the page you requested is clearly in the directory.

Therefore, when the request returns 404, we need to analyze the situation based on the specific cause, whether the actual resource cannot be found, or other reasons.

Even if you have configured multiple error codes to correspond to the same 404 error page, each time you see 404, it may be another reason.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.