【问题标题】:Java web application error, probably in web.xmlJava Web 应用程序错误,可能在 web.xml 中
【发布时间】:2014-01-27 09:34:05
【问题描述】:

我创建了一个 Hello World servlet,并使用 tomcat 在本地服务器上运行它。它运行良好。

然后,我尝试将其映射到 url 模式,页面显示错误The requested resource (/hello) is not available.

谁能帮帮我。刚开始使用 Java EE。任何学习/实践的好资源也很感激。

我的 hello world servlet 位于: workspace\TestServletsApplication\src\com\msusevusal

我的 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">

<display-name>TestServletsApplication</display-name>
  <servlet>
      <servlet-name>TestServlet</servlet-name>
      <servlet-class>com.msusevusal.TestServlet</servlet-class>
  </servlet>
  <servlet-mapping>
      <servlet-name>TestServlet</servlet-name>
      <url-pattern>/hello</url-pattern>
  </servlet-mapping>
</web-app>

【问题讨论】:

  • 您要访问的 URL 是什么?
  • 在本地服务器上运行,localhost:8080/hello
  • 你能发布你的servlet的内容吗?

标签: java xml jakarta-ee tomcat servlets


【解决方案1】:

你的tomcat配置是什么? 如果您将应用程序放在 %tomcat_home%/webapps 目录中,则 url 应该是 本地主机:8080/appName/你好

【讨论】:

  • @r 不要将问题的名称设置为“已解决”,只需接受答案即可。
猜你喜欢
  • 2011-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-04
  • 2013-04-29
  • 2021-07-11
  • 2011-05-22
相关资源
最近更新 更多