日期:2014-05-18  浏览次数:20717 次

tomcat发布helloworld怎么都出错拉?!!!!
我的步骤是:
1、编写HelloWorld.java.
2、编译HelloWorld.java....生成的HelloWorld.class放到%CATALINA_HOME%\webapps\helloworld\WEB-INF\classes文件下
3、在%CATALINA_HOME%\webapps\helloworld\WEB-INF\建立web.xml文件。内容如下:
<?xml   version= "1.0 "   encoding= "ISO-8859-1 "?>
<web-app   xmlns= "http://www.abc.com "
        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 "
        version= "2.4 ">

        <servlet>
                <servlet-name> helloworld </servlet-name>
                <servlet-class> HelloWorld </servlet-class>
        </servlet>

        <servlet-mapping>
                <servlet-name> helloworld </servlet-name>
                <url-pattern> /hello </url-pattern>
        </servlet-mapping>
</web-app>


结果我在浏览器里连接http://localhost:8080/helloworld/hello时出现:代号为404的错误,即找不到hello这个东西。。

咋办??

------解决方案--------------------
HelloWorld前面有没有包名?
------解决方案--------------------
对,将HelloWorld的代码也贴出来看看,看有没有包名
------解决方案--------------------

一,你写的HelloWorld 是否为Servlet ?

二,如果你写的HelloWorld是Servlet,请把它放入某个包内,如:com.tom.HelloWorld,修改Web.xml ,自然可访问到。