我在默认路径下DefaultWebApp\WEB-INF\classes下建了servlet文件a.java 修改web.xml文件如下: <servlet> <servlet-name>a</servlet-name> <servlet-class>a</servlet-class> </servlet> <servlet-mapping> <servlet-name>a</servlet-name> <url-pattern>/myservlet</url-pattern> </servlet-mapping> 我输处http://localhost:7001/myservlet/a 出现错误,这是为什么? Error 404--Not Found From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1: 10.4.5 404 Not Found The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.
修改web.xml文件如下:
<servlet>
<servlet-name>a</servlet-name>
<servlet-class>a</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>a</servlet-name>
<url-pattern>/myservlet</url-pattern>
</servlet-mapping>
我输处http://localhost:7001/myservlet/a 出现错误,这是为什么?
Error 404--Not Found
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.5 404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>myjsp</display-name>
<module>
<web>
<web-uri>myjsp</web-uri>
<context-root>myjsp</context-root>
</web>
</module>
</application>新建目录myjsp/myjsp,再建web-inf
然后在web-inf下建立web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>servlet name</servlet-name>
<servlet-class>servlet class</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlet name</servlet-name>
<url-pattern>/servlet name</url-pattern>
</servlet-mapping>
</web-app>web-inf下建立classes目录,把jb的输出路径制定为这个classes.
ok
我实在有点不懂了,我做过TOMCAT,好象调用SERVLET没这么麻烦
用JBUILDER生成的一堆乱七八糟的东西都是做什么用的
谢谢zez
至少,得有个规范的根目录吧,不然j2ee服务器怎么读取呢?