Java 尝试在 Eclipse 中运行 jsp 文件时出现 HTTP 404

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20779554/
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-13 04:16:34  来源:igfitidea点击:

HTTP 404 when trying to run a jsp file in eclipse

javajsptomcateclipse-plugin

提问by

I get 404 error when trying to run a jsp file eclipse. The confusing thing is the server is running and I can go to localhost:8080without any problems. I have attached an image of my configuration of server, the jsp file and also the location of the file and the error.

尝试运行 jsp 文件 eclipse 时出现 404 错误。令人困惑的是服务器正在运行,我可以localhost:8080毫无问题地去。我附上了我的服务器配置图像、jsp 文件以及文件的位置和错误。

enter image description here

enter image description here

I embed the image cause of the reputation thing so I have linked it

我嵌入了声誉事物的图像原因,所以我已经链接了它

More information:

更多信息:

I am using TOMCAT 7, ECLIPSE KEPLER I have checked the location of helloworld.jspits in WebContent. I have restarted the server. I have created another dynamic web project nothing works. I get the same problem I can go to localhost:8080but I cant run an JSP file

我正在使用 TOMCAT 7,ECLIPSE KEPLER 我已经检查了helloworld.jsp它在 WebContent 中的位置。我已经重新启动了服务器。我创建了另一个动态 Web 项目,但没有任何效果。我遇到了同样的问题,localhost:8080但我无法运行 JSP 文件

SOLVED:

解决了:

Okay guys its pretty simple to solve this problem. There are two things you need to try.

好吧伙计们解决这个问题很简单。您需要尝试两件事。

1)Right click your project and export the war file into C:\ProgramFiles\Tomcat7folder If this does not work then.

1)右键单击您的项目并将war文件导出到C:\ProgramFiles\Tomcat7文件夹如果这不起作用那么。

2) Right click your project and export the war file into some directory and copy the war file into C:\ProgramFiles\Tomcat7then start the Tomcat server and there you go your JSP file work.

2)右键单击您的项目并将war文件导出到某个目录并将war文件复制到C:\ProgramFiles\Tomcat7然后启动Tomcat服务器,然后您的JSP文件就可以开始工作了。

You will probably end up doing step 2 because of stupid windows file permissions

由于愚蠢的 Windows 文件权限,您可能最终会执行第 2 步

Also thanks for all the help guys really appreciate it.

也感谢所有帮助家伙真的很感激。

回答by Pankaj Jawale

Since you do not have any of them

因为你没有他们中的任何一个

index.html/index.htm/index.jsp/default.html/default.htm/default.jsp page

To run your jsppage :

要运行您的jsp页面:

In Eclipse:

在日食中:

=>goto Java Resource

=> 转到 Java 资源

=>right click on your jsp page

=>右键单击您的jsp页面

=>in that select Run as Server.

=> 在其中选择作为服务器运行。

回答by Krishna

Make sure that u have put your Jsp files into the WebRoot and check the location and even check your Web.xml and after that run and still if its not working then post your Web.xml here.

确保您已将您的 Jsp 文件放入 WebRoot 并检查位置,甚至检查您的 Web.xml,然后运行,如果它仍然不起作用,则在此处发布您的 Web.xml。

回答by Roman Wang

Unfortunately, user3135774's solution does not work for me, as am using an Apple computer.

不幸的是,user3135774 的解决方案对我不起作用,因为我使用的是 Apple 计算机。

I have read and researched another problem(Error 500: No Output Folder), which I have along with Error 404, carefully, and I think this is related to permission issues.

我仔细阅读并研究了另一个问题(错误 500:无输出文件夹),它与错误 404 一起出现,我认为这与权限问题有关。

The JSP file is supposed to be compiled and then deployed under Tomcat/work/Catalina/localhost/YourProjectName. The 404 error message means that there is no files in that directory. Since Eclipse has no write permission to this directory, you have to change the access permissions. After changing the permission to 777, there we have the compiled .java and .class files.

JSP 文件应该被编译,然后部署在Tomcat/work/Catalina/localhost/YourProjectName. 404 错误消息表示该目录中没有文件。由于 Eclipse 对该目录没有写权限,因此您必须更改访问权限。将权限更改为 后777,我们就有了编译好的 .java 和 .class 文件。

回答by DSDS

After applying everythings, it did not work for me to read image file in eclips.

应用所有内容后,我无法读取 eclips 中的图像文件。

Finally, It works! after that I change deploy path.

最后,它有效!之后我更改部署路径。

Server Locations>Deploy path(Set with "Workspace" of Eclipse)

Server Locations>Deploy path(用Eclipse的“Workspace”设置)

enter image description here

enter image description here