Java 如何解决servlet jsp中的错误http状态404

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3590066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 02:16:31  来源:igfitidea点击:

how to solve error http status 404 in servlet jsp

javajsptomcatservlets

提问by user399082

I am trying to run some basic servlet and jsp program with Tomcat. but it gives some error. I am using Tomcat 6.0.29 and jdk 1.6.0_21.

我正在尝试使用 Tomcat 运行一些基本的 servlet 和 jsp 程序。但它给出了一些错误。我正在使用 Tomcat 6.0.29 和 jdk 1.6.0_21。

When i click on WebAppl link in Tomcat then it gives below error

当我单击 Tomcat 中的 WebAppl 链接时,它会出现以下错误

HTTP Status 404 - /WebAppl/

type Status report

message /WebAppl/

description The requested resource (/WebAppl/) is not available.   

I tried another code which was running properly on Tomcat 5.5.9. But still gives same error here.

我尝试了另一个在 Tomcat 5.5.9 上正常运行的代码。但这里仍然给出同样的错误。

HTTP Status 404 - /SampleAppl/

type Status report

message /SampleAppl/

description The requested resource (/SampleAppl/) is not available.

What should I do to solve this error?

我应该怎么做才能解决这个错误?

Is it because of new version of Tomcat? Can anyone guide me.

是不是因为新版本的Tomcat?谁能指导我。

回答by Thorbj?rn Ravn Andersen

Either you are not using the right URL to access the web application, or you had an error when deploying. Have a look at the Tomcat server logs to see if there is anything in there.

您没有使用正确的 URL 来访问 Web 应用程序,或者您在部署时出错。查看 Tomcat 服务器日志以查看其中是否有任何内容。

Also the management console might help you getting the URL right.

此外,管理控制台可能会帮助您正确获取 URL。

回答by Peter Tillemans

It looks like your web applications are not deployed. Check carefully the log files of the booting of your tomcat. It will indicate when it starts deploying your webapps and why they failed.

看起来您的 Web 应用程序尚未部署。仔细检查tomcat启动的日志文件。它将指示何时开始部署您的 web 应用程序以及它们失败的原因。

The stacktraces stick out like a sore thumb and following the Up, or looking in down for 'Caused By' lines usually gives a reason why they do not deploy.

堆栈跟踪像拇指酸痛一样突出并跟随向上或向下寻找“由”行通常会给出它们不部署的原因。

If you are stumped you may want to post some parts to this site to ask for guidance.

如果您被难住了,您可能想将一些部分发布到此站点以寻求指导。

回答by extraneon

You say you are using tomcat. In that case check the $tomcat/webapps directory. There should be a WebAppland a SampleAppldirectory (and/or war) in there.

你说你用的是tomcat。在这种情况下,请检查 $tomcat/webapps 目录。那里应该有一个WebAppl和一个SampleAppl目录(和/或War)。

Als check the $tomcat/logs directory and read catalina.out(the logfile). Check for Exceptions and the text deployed. You would expect that it says that application WebAppl is deployed.

也检查 $tomcat/logs 目录并阅读catalina.out(日志文件)。检查异常和部署的文本。您会期望它说应用程序 WebAppl 已部署。

Of course,you do have to connect to your tomcat. Tomcat is usually listening in port 8080 (check $tomcat/conf/servlet.xml). It could be that you are connecting to another application at port 80 (the http default, usually Apache or IIS).

当然,你必须连接到你的tomcat。Tomcat 通常监听 8080 端口(检查 $tomcat/conf/servlet.xml)。可能是您在端口 80(http 默认值,通常是 Apache 或 IIS)连接到另一个应用程序。

If it is in port 8080, your URL should look like: http://localhost:8080/WebAppl

如果它在端口 8080 中,您的 URL 应如下所示: http://localhost:8080/WebAppl

回答by Ajay Takur

Might be

可能

1)Don't violate folder creation structure hierarchy and place corresponding files

1)不要违反文件夹创建结构层次,放置相应文件

2)web applications are not deployed

2)未部署Web应用程序

3)right URL to access the web application

3) 访问 Web 应用程序的正确 URL

4)Container not yet started(because check out the port numbers that may clash with earlier configured setups )

4)容器尚未启动(因为检查可能与早期配置的设置冲突的端口号)

回答by ashishksh

Your project hierarchy is the one that needs to be checked project- src- servlet

您的项目层次结构是需要检查的项目- src- servlet

    webcontent-
               web-inf-
                       web.xml
               index.jsp

Your url will be http://localhost:8080/project

您的网址将是 http://localhost:8080/project

回答by Vivek Gulati

It could be due to missing tld files in WEB-INFdirectory which are being used, inside JSP, example JSTL Core.

这可能是由于WEB-INF在 JSP 内部正在使用的目录中缺少 tld 文件,例如 JSTL Core。

<c:out value="${salary}"/>