它在带有eclipse的tomcat servlet中不起作用

时间:2012-08-29 18:01:18

标签: java eclipse tomcat servlets

我已经使用eclipse安装了tomcat,并且我有一个带有servlet的项目。在这里我把两者的结构:

enter image description here

直到今天,运行servlet的步骤是:

1.按下以下按钮并给出“开始” Tomcat

enter image description here

2.一旦启动,在“UsuarioServlet.java”上按右键/在服务器上运行/运行

enter image description here

完成所有工作正常但突然今天这样做我得到以下内容:

enter image description here

发生了什么事??

1 个答案:

答案 0 :(得分:0)

我最近遇到了这个问题。

这对我有所帮助。 启动tomcat并在控制台中搜索运行tomcat的真实路径。 去那里打开conf/server.xml。集成了tomcat和eclipse的插件在那里增加了一条长线。向下滚动以查看它。以下是这条线在我的机器上的样子。

  <Context docBase="C:\workspaces\work7\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ROOT" path="" reloadable="false"/><Context debug="0" docBase="C:\workspaces\work7\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\webapp" path="/mycompany-webapp-0.9-SNAPSHOT" reloadable="true" source="org.eclipse.jst.jee.server:webapp">
<Valve className="org.apache.catalina.valves.AccessLogValve" pattern="common" prefix="access_log." suffix=".txt"/>

请注意路径属性。它曾经是/webapp但现在变为/mycompany-webapp-0.9-SNAPSHOT。因此,这是部署应用程序的真实URL。

我曾经使用网址http://localhost:8080/webapp浏览我的应用程序。 现在我必须使用http://localhost:8080/mycompany-webapp-0.9-SNAPSHOT。 或者,我可以停止服务器,手动修复server.xml中的路径,启动服务器并使用“旧”URL。

关键是这种行为不一致。有时(当项目设置被更改时)此问题会“自动”修复,但有时会返回。它不仅发生在我的机器上,还发生在我工作的公司中其他2名团队成员的计算机上。

我希望这些信息对您有所帮助。祝你好运。