我无法在apache tomcat中部署基本的html文件 [英] I cannot deploy a basic html file in apache tomcat

查看:139
本文介绍了我无法在apache tomcat中部署基本的html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个小型网站,这是我的第一个项目.我最终确定要在服务器端脚本中使用Java Servlet和JSP.我正在从O'Reilly的HeadFirst Servlet和JSP学习.我决定使用Apache-Tomcat作为我的Web服务器和容器.我下载了.我什至拥有jdk 1.6 update 21. 我在C中解压缩了Apache: 当我在浏览器中键入 http://localhost:8080 时,它成功运行,并获得默认的Tomcat主页.

I am making a small website as my first project. I have finalized to use Java Servlets and JSP for my Server-side scripting. I am learning it from O'Reilly's HeadFirst Servlets and JSP. I decided to use Apache-Tomcat as my web server and container. I downloaded it. I even have jdk 1.6 update 21. I unzipped apache in C: It is running successfully as i get the default Tomcat home page when I type http://localhost:8080 in my browser.

在第3章中,有一个名为啤酒的小项目. 所以我试图做到这一点. 我在webapps C:\apache-tomcat-7.0.0\webapps\beer下创建了一个名为Beer的目录.在其中仅检查基础知识,我创建了一个名为form.html的html文件.但是,当我尝试通过浏览器http://localhost:8080/beer/form.html访问它时,出现以下错误:

In chapter 3 there is a small project called beer. So I tried to make it. I created a directory called beer under webapps C:\apache-tomcat-7.0.0\webapps\beer. Inside it to just check the basics I created a html file called form.html. But when I try to access it via the browser http://localhost:8080/beer/form.html I get the following error:

HTTP状态404-/beer/form.html

HTTP Status 404 - /beer/form.html

类型状态报告

消息/beer/form.html

message /beer/form.html

描述所请求的资源 (/beer/form.html)不可用.

description The requested resource (/beer/form.html) is not available.

Apache Tomcat/7.0.0

Apache Tomcat/7.0.0

我什至尝试使用tomcat 6,但没有用.

I have even tried using tomcat 6, but to no use.

感谢您的回复... 其实我的怀疑是..我在这里试图访问一个不是servlet的.html文件,所以它甚至需要Deployment描述吗??

Thank you for replying... Actually my doubt is..that here i am trying to access a .html file which is not a servlet so does it even require a Deployment description????

好吧,我计划只(最初)创建一个servlet....在我创建的html文件中以(动作="....")的形式提到的那个servlet. 所以我想在部署servlet .... btw ...之前先检查基本的html文件...如果我还必须在DD中包含html文件,那么我应该在您提供的xml代码中代替ServletName写什么? 这是我的web.xml的内容(我按照您所说的进行了修改...但是不知道在Servlet名称中写什么)

well, there is only 1 servlet i planned to make (initially)....the one which is mentioned in the form (action= "....") in the html file i made.... so i thought of checking the basic html file before i deployed a servlet....btw...if i have to include the html file also in the DD, then what should i write in place of ServletName in the xml code u gave? here are the contents of my web.xml (i modified it as u said...but dunno what to write in the Servlet Name)

<?xml version="1.0" encoding="utf-8"?>
 <web-app 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/web-app_2_4.xsd" version="2.4">
    <servlet>
        <servlet-name>html page</servlet-name>
        <servlet-class>form</servlet-class>
    </servlet>
    <servlet-mapping>
      <servlet-name>html page</servlet-name>
      <url-pattern>/beer/form.html</url-pattern>
   </servlet-mapping>


    <servlet>
        <servlet-name>Ch3 Beer</servlet-name>
        <servlet-class>com.example.web.BeerSelect</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Ch3 Beer</servlet-name>
        <url-pattern>/SelectBeer.do</url-pattern>
    </servlet-mapping>
</web-app>

推荐答案

它应该可以正常工作.网址或文件名中可能有错字.它也是区分大小写的. /Beer/beer不同.仔细检查网址.另外,您没有运行或从下载的zip中提取的Tomcat的多个实例吗?您可能将新页面放置在错误的页面和/或运行错误的页面.尝试关闭您认为正在运行的Tomcat实例,然后在Web浏览器中重新加载主页.如果首页没有消失,那就是另外一个.

It should work just fine. Probably a typo in URL or filename. It's case sensitive as well. /Beer is not the same as /beer. Doublecheck the URL. Also, don't you have multiple instances of Tomcat running or extracted from the downloaded zip? You might have placed the new page in the wrong one and/or be running the wrong one. Try shutting down the Tomcat instance you think you're running and reload the homepage in the webbrowser. If the homepage doesn't disappear, then it's a different one.

这篇关于我无法在apache tomcat中部署基本的html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆