【问题标题】:Tomcat servlet mapping: why does examples directory in url and not in web.xmlTomcat servlet 映射:为什么示例目录在 url 而不是 web.xml
【发布时间】:2016-05-24 16:18:37
【问题描述】:

安装Tomcat后可以浏览http://localhost:8080/examples/servlets/servlet/HelloWorldExample

为什么不是 http://localhost:8080/servlets/servlet/HelloWorldExample

因为 examples 在 Servlet-Mapping 中没有被引用?

<servlet-mapping>
    <servlet-name>HelloWorldExample</servlet-name>
    <url-pattern>/servlets/servlet/HelloWorldExample</url-pattern>
</servlet-mapping>

【问题讨论】:

  • examplessimply 不是上下文吗?

标签: java tomcat servlets


【解决方案1】:

examples 是部署在 Tomcat 上的 examples Web 应用程序的上下文路径。仅对于 ROOT 上下文,您在 servlet 映射和 servlet url 中具有相同的 url。

【讨论】:

    【解决方案2】:

    也许这是答案:

    Tomcat 在 “\webapps\examples”。保留 servlet 源文件 在“\webapps\examples\WEB-INF\classes”下,一起 与编译的类。要运行示例,请启动 Tomcat 服务器。 问题网址http://localhost:8080/examples。

    https://www.ntu.edu.sg/home/ehchua/programming/java/JavaServletExamples.html

    【讨论】:

      猜你喜欢
      • 2016-02-05
      • 1970-01-01
      • 2012-04-17
      • 2018-11-24
      • 1970-01-01
      • 2015-03-01
      • 2013-01-20
      • 2010-10-04
      • 2019-08-07
      相关资源
      最近更新 更多