简体   繁体   English

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

[英]It does not work in tomcat servlet with eclipse

I have installed tomcat with eclipse and I have a project with a servlet. 我已经安装了带有eclipse的tomcat,并且我有一个带有servlet的项目。 Here I put the structure of both: 在这里,我将两者的结构都放在这里:

在此处输入图片说明

Until this day the steps followed to run the servlet were: 到目前为止,运行servlet的步骤如下:

1.Press button right above the following and give "Start" Tomcat 1.按以下按钮右上方的,并给“开始” Tomcat

在此处输入图片说明

2.Once booted, press right button over "UsuarioServlet.java" / Run as / Run on server 2.启动后,在“ UsuarioServlet.java”上按右键/作为/在服务器上运行

在此处输入图片说明

Done that everything worked properly but suddenly today when doing so I get the following: 完成一切工作正常,但是今天突然这样做,我得到以下信息:

在此处输入图片说明

What happened?. 发生了什么?。

I had this problem recently. 我最近有这个问题。

Here is what helped me. 这是帮助我的。 Start tomcat and search in the console the real path where your tomcat is running. 启动tomcat,然后在控制台中搜索tomcat运行的实际路径。 Go there and open conf/server.xml . 去那里打开conf/server.xml The plug-in that integrates tomcat and eclipse adds one long line there. 集成了tomcat和eclipse的插件在那里增加了一行。 Scroll down to see it. 向下滚动以查看它。 Here is how this line looks on my machine. 这条线在我的机器上看起来是这样。

  <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"/>

Please pay attention on path attribute. 请注意路径属性。 It used to be /webapp but now it became /mycompany-webapp-0.9-SNAPSHOT . 它曾经是/webapp但现在变成了/mycompany-webapp-0.9-SNAPSHOT So, this is the real URL where the application is deployed. 因此,这是部署应用程序的真实URL。

I used to surf to my application using url http://localhost:8080/webapp . 我曾经使用url http://localhost:8080/webapp来浏览我的应用程序。 Now I have to use http://localhost:8080/mycompany-webapp-0.9-SNAPSHOT . 现在,我必须使用http://localhost:8080/mycompany-webapp-0.9-SNAPSHOT Alternatively I can stop server, fix the path in server.xml manually, start server and use the "old" URL. 或者,我可以停止服务器,手动修复server.xml的路径,启动服务器并使用“旧” URL。

The point is that this behavior is not consistent. 关键是这种行为是不一致的。 Sometimes (when project settings are being changed) this problem is fixed "automatically" but sometimes it returns. 有时(更改项目设置时)“自动”解决了此问题,但有时又返回了。 It happened not only on my machine but on computers of 2 other team members in company where I work. 它不仅发生在我的机器上,而且发生在我工作的公司中其他2个团队成员的计算机上。

I hope this information will help you. 希望这些信息对您有所帮助。 Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM