[英]running and deploying servlet with eclipse and tomcat 7
Page cannot be found
at 127.0.0.1/helloworld/HelloWorld Page cannot be found
在127.0.0.1/helloworld/HelloWorld HTTP Status 404
HTTP Status 404
Next, in HelloWorld.java, I tried commenting out 接下来,在HelloWorld.java中,我尝试了注释
//@WebServlet("/HelloWorld")
and then adding a web-application-specific web.xml configuration: 然后添加特定于Web应用程序的web.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
But the results are still the same - no response! 但结果仍然相同 - 没有回应!
@WebServlet("/HelloWorld")
added by Eclipse sufficient? @WebServlet("/HelloWorld")
足够? What is needed for the annotation-based configuration of Servlet 3.0 to work (without web.xml)? 打开动态Web项目的属性页面,单击“Web项目设置”,然后使用上下文根参数作为URL的根路径。
Try putting a default Index.html page in the WebContent and see if the welcome page points to it. 尝试在WebContent中放置一个默认的Index.html页面,看看欢迎页面是否指向它。 If yes then try entering the servlet name manually and see if that works.
如果是,则尝试手动输入servlet名称,看看是否有效。 I get the same error but doing so fixes it.
我得到了同样的错误,但这样做可以解决它。
http://localhost:8080/<Project_Name>/index.html
http://localhost:8080/<Project_Name>/servlet_name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.