【问题标题】:war servlet tomcat cannot findwar servlet tomcat 找不到
【发布时间】:2011-03-01 17:03:48
【问题描述】:

我从 eclipse 中将我的 servlet 项目导出为一个 war 文件,并将它放在 webapp/hello 文件夹中。

/webapps/hello/hellotest.war

如何运行它?

我输入了这个

http://127.0.0.1:8080/hello/foo

但运行失败

这是我在war文件中的web.xml文件

 <?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>helloTest</display-name>
    <servlet>
        <description>
        </description>
        <display-name>foo</display-name>
        <servlet-name>foo</servlet-name>
        <servlet-class>
        foo</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>foo</servlet-name>
        <url-pattern>/foo</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
</web-app>

【问题讨论】:

  • 我假设您使用的是tomcat?重启tomcat后webapps下的目录结构是什么?

标签: java tomcat servlets


【解决方案1】:

将您的hellotest.war 文件放在Tomcat 的webapps 文件夹中。假设您的 Tomcat 实例正在运行并正确设置,它应该自动将应用程序部署到文件夹 webapps/hellotest。然后,您可以从 URL http://127.0.0.1:8080/hellotest/ 访问您的应用程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多