Topic: 请教Tomcat中Servlet的问题. |
Print this page |
1.请教Tomcat中Servlet的问题. | Copy to clipboard |
Posted by: dytiger Posted on: 2003-09-18 07:37 为什么我把Servlet的class文件放在tomcat\Webapps\ch03\WEB-INF\classes\com\dytiger\servlets目录中下, 用Http://localhost/ch03/servlet/com.dytiger.servlets显示,IE总是报404错误?而examples下的官方的 Servlet例程确没问题呢? JAVA_HOME和CLASSPATH等书上说的参数都设置正确了,而且在编译后也重新启动Tomcat了.请前辈指教,谢谢. 代码是: package com.dytiger.servlets import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class FirstServlets extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out; String title = "Servlet Example"; response.setContentType("text/html"); out = response.getWriter(); out.println("<html><head><title>"); out.println(title); out.println("</title></head><body>"); out.println("<h1>This is an example servlet.</h1>"); out.println("</body></html>"); out.close(); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } |
2.Re:请教Tomcat中Servlet的问题. [Re: dytiger] | Copy to clipboard |
Posted by: nothing Posted on: 2003-09-18 07:48 配置问题. |
3.Re:请教Tomcat中Servlet的问题. [Re: dytiger] | Copy to clipboard |
Posted by: looluo Posted on: 2003-09-18 08:20 研究一下web.xml |
4.Re:请教Tomcat中Servlet的问题. [Re: nothing] | Copy to clipboard |
Posted by: ringayumi Posted on: 2003-09-18 09:16 try it => Http://localhost/ch03/servlet/com.dytiger.servlets.FirstServlets good luck! |
5.Re:请教Tomcat中Servlet的问题. [Re: dytiger] | Copy to clipboard |
Posted by: ringayumi Posted on: 2003-09-18 09:19 if you not change the port 8080~ you can try it => Http://localhost:8080/ch03/servlet/com.dytiger.servlets.FirstServlets |
6.Re:请教Tomcat中Servlet的问题. [Re: dytiger] | Copy to clipboard |
Posted by: dytiger Posted on: 2003-09-18 11:10 在WEB-INF目录下添加web.xml文件,问题解决.以下是XML文件的内容. <?xml version="1.0" encoding="ISO-8859-1"?> <!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-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> </web-app> |
7.Re:请教Tomcat中Servlet的问题. [Re: dytiger] | Copy to clipboard |
Posted by: samx Posted on: 2003-09-18 12:05 其实,你在\\Tomcat Home\conf\的web.xml内注释的这段内容去掉注释后,就不用在每个 Web model 的web.xml设置了. 另外,你还在用Tomcat 3吗? Tomcat 新版本应该没有这个问题. |
8.Re:请教Tomcat中Servlet的问题. [Re: dytiger] | Copy to clipboard |
Posted by: dytiger Posted on: 2003-09-18 13:07 谢谢samx的回复,谢谢! BTW:我用的是Tomcat 4.1.24 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |