[英]Tomcat servlet mapping: why does examples directory in url and not in web.xml
After installing Tomcat you can browse http://localhost:8080/ examples /servlets/servlet/HelloWorldExample 安装Tomcat之后,您可以浏览http:// localhost:8080 / examples / servlets / servlet / HelloWorldExample
Why it isn't http://localhost:8080/servlets/servlet/HelloWorldExample 为什么不是http:// localhost:8080 / servlets / servlet / HelloWorldExample
since examples is not refered to in Servlet-Mapping ? 因为在Servlet-Mapping中未引用示例 ?
<servlet-mapping>
<servlet-name>HelloWorldExample</servlet-name>
<url-pattern>/servlets/servlet/HelloWorldExample</url-pattern>
</servlet-mapping>
Maybe this answers: 也许这个答案:
Tomcat provides a number of excellent servlet examples in "\\webapps\\examples". Tomcat在“ \\ webapps \\ examples”中提供了许多出色的servlet示例。 The servlet source files are kept under "\\webapps\\examples\\WEB-INF\\classes", together with the compiled classes. Servlet源文件与已编译的类一起保存在“ \\ webapps \\ examples \\ WEB-INF \\ classes”下。 To run the examples, start Tomcat server. 要运行示例,请启动Tomcat服务器。 Issue URL http://localhost:8080/examples . 发出URL http:// localhost:8080 / examples 。
https://www.ntu.edu.sg/home/ehchua/programming/java/JavaServletExamples.html https://www.ntu.edu.sg/home/ehchua/programming/java/JavaServletExamples.html
examples is a context path for examples web application deployed on Tomcat. examples是在Tomcat上部署的示例 Web应用程序的上下文路径。 Only for ROOT context you have the same url in servlet mapping and servlet url. 仅对于ROOT上下文,您在servlet映射和servlet url中具有相同的url。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.