可是,部署上去之后,一点Submit按钮,就说找不到Servlet。
请大家帮我看看好吗?
我的Web Container是jakarta-tomcat-5.0.19
Oracle 9i
报的错误是:
HTTP Status 404 - /tech-support/servlet/TechSupportServlet
--------------------------------------------------------------------------------
type Status report
message /tech-support/servlet/TechSupportServlet
description The requested resource (/tech-support/servlet/TechSupportServlet) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.19
25 个解决方案
#1
楼主,请详细说明一下,你的类文件是如何放的,应该放到 web-inf/classes的文件下
#2
楼上讲的是一点
另外地址栏中url注意,尤其是端口。。
另外地址栏中url注意,尤其是端口。。
#3
下面是我的目录结构:
%tomcat_home%\webapps\tech-support\index.html
%tomcat_home%\webapps\tech-support\WEB-INF\web.xml
%tomcat_home%\webapps\tech-support\WEB-INF\classes\DbConnection.class
%tomcat_home%\webapps\tech-support\WEB-INF\classes\Sequencer.class
%tomcat_home%\webapps\tech-support\WEB-INF\classes\TechSupportServlet.class
下面是web.xml的内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet Learning</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
</web-app>
请高手帮我看看,谢谢了。
%tomcat_home%\webapps\tech-support\index.html
%tomcat_home%\webapps\tech-support\WEB-INF\web.xml
%tomcat_home%\webapps\tech-support\WEB-INF\classes\DbConnection.class
%tomcat_home%\webapps\tech-support\WEB-INF\classes\Sequencer.class
%tomcat_home%\webapps\tech-support\WEB-INF\classes\TechSupportServlet.class
下面是web.xml的内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet Learning</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
</web-app>
请高手帮我看看,谢谢了。
#4
真的是郁闷,这么简单都搞不定
#5
我认为还是web.xml的问题
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet Learning</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
</web-app>
<servlet-mapping>
<servlet-name>TechSupportServlet</servlet-name>
<url-pattern>/TechSupportServlet</url-pattern> //请注意这里是否设置正确了,
//另外注意Jsp页面中调 //这个servlet时大小写是否一致
</servlet-mapping>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet Learning</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
</web-app>
<servlet-mapping>
<servlet-name>TechSupportServlet</servlet-name>
<url-pattern>/TechSupportServlet</url-pattern> //请注意这里是否设置正确了,
//另外注意Jsp页面中调 //这个servlet时大小写是否一致
</servlet-mapping>
#6
调用servlet的时候,action="/techSupportServlet"
action后面的是<url-pattern>/TechSupportServlet</url-pattern>中的部分,T小写
action后面的是<url-pattern>/TechSupportServlet</url-pattern>中的部分,T小写
#7
web.xml内容改成如下试试
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>//这是在浏览时的url
</servlet-mapping>
</web-app>
然后在提交时提交到http://localhost:8080/tech
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>//这是在浏览时的url
</servlet-mapping>
</web-app>
然后在提交时提交到http://localhost:8080/tech
#8
各位老大的方法我都一一试过了,奇迹没有出现,还是老样子。
CoolAbu,我在HTML页面中是这样写的:
<FORM ACTION="/tech" METHOD="POST">
可是还是报错:
HTTP Status 404 - /tech
--------------------------------------------------------------------------------
type Status report
message /tech
description The requested resource (/tech) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.19
CoolAbu,我在HTML页面中是这样写的:
<FORM ACTION="/tech" METHOD="POST">
可是还是报错:
HTTP Status 404 - /tech
--------------------------------------------------------------------------------
type Status report
message /tech
description The requested resource (/tech) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.19
#9
下面是我的HTML页面代码:
<HTML>
<HEAD>
<TITLE>XYZ Corporation, IT Department</title>
</HEAD>
<BODY>
<H1>Technical Support Request</H1>
<HR><BR>
<CENTER>
<FORM ACTION="/tech" METHOD="POST">
<TABLE ALIGN="center" WIDTH="100%" CELLSPACING="2" CELLPADDING="2">
<TR>
<TD ALIGN="right">First Name:</TD>
<TD><INPUT TYPE="Text" NAME="firstName" ALIGN="LEFT" SIZE="15"></TD>
<TD ALIGN="right">Last Name:</TD>
<TD><INPUT TYPE="Text" NAME="lastName" ALIGN="LEFT" SIZE="15"></TD>
</TR>
<TR>
<TD ALIGN="right">Email:</TD>
<TD><INPUT TYPE="Text" NAME="email" ALIGN="LEFT" SIZE="25"></TD>
<TD ALIGN="right">Phone:</TD>
<TD><INPUT TYPE="Text" NAME="phone" ALIGN="LEFT" SIZE="15"></TD>
</TR>
<TR>
<TD ALIGN="right">Software:</TD>
<TD>
<SELECT NAME="software" SIZE="1">
<OPTION VALUE="Word">Microsoft Word</OPTION>
<OPTION VALUE="Excel">Microsoft Excel</OPTION>
<OPTION VALUE="Access">Microsoft Access</OPTION>
</SELECT>
</TD>
<TD ALIGN="right">Operating System:</TD>
<TD>
<SELECT NAME="os" size="1">
<OPTION VALUE="95">Windows 95</OPTION>
<OPTION VALUE="98">Windows 98</OPTION>
<OPTION VALUE="NT">Windows NT</OPTION>
</SELECT>
</TD>
</TR>
</TABLE>
<BR>Problem Description
<BR>
<TEXTAREA NAME="problem" COLS="50" ROWS="4"></TEXTAREA>
<HR><BR>
<INPUT TYPE="Submit" NAME="submit" VALUE="Submit Request">
</FORM>
</CENTER>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>XYZ Corporation, IT Department</title>
</HEAD>
<BODY>
<H1>Technical Support Request</H1>
<HR><BR>
<CENTER>
<FORM ACTION="/tech" METHOD="POST">
<TABLE ALIGN="center" WIDTH="100%" CELLSPACING="2" CELLPADDING="2">
<TR>
<TD ALIGN="right">First Name:</TD>
<TD><INPUT TYPE="Text" NAME="firstName" ALIGN="LEFT" SIZE="15"></TD>
<TD ALIGN="right">Last Name:</TD>
<TD><INPUT TYPE="Text" NAME="lastName" ALIGN="LEFT" SIZE="15"></TD>
</TR>
<TR>
<TD ALIGN="right">Email:</TD>
<TD><INPUT TYPE="Text" NAME="email" ALIGN="LEFT" SIZE="25"></TD>
<TD ALIGN="right">Phone:</TD>
<TD><INPUT TYPE="Text" NAME="phone" ALIGN="LEFT" SIZE="15"></TD>
</TR>
<TR>
<TD ALIGN="right">Software:</TD>
<TD>
<SELECT NAME="software" SIZE="1">
<OPTION VALUE="Word">Microsoft Word</OPTION>
<OPTION VALUE="Excel">Microsoft Excel</OPTION>
<OPTION VALUE="Access">Microsoft Access</OPTION>
</SELECT>
</TD>
<TD ALIGN="right">Operating System:</TD>
<TD>
<SELECT NAME="os" size="1">
<OPTION VALUE="95">Windows 95</OPTION>
<OPTION VALUE="98">Windows 98</OPTION>
<OPTION VALUE="NT">Windows NT</OPTION>
</SELECT>
</TD>
</TR>
</TABLE>
<BR>Problem Description
<BR>
<TEXTAREA NAME="problem" COLS="50" ROWS="4"></TEXTAREA>
<HR><BR>
<INPUT TYPE="Submit" NAME="submit" VALUE="Submit Request">
</FORM>
</CENTER>
</BODY>
</HTML>
#10
下面是修改之后的web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>
</servlet-mapping>
</web-app>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>
</servlet-mapping>
</web-app>
#11
你把Tomcat重启一次,然后用下面这个试试http://locahost:8080/tech-support/tech
Servlet基本上就是这样部署的,多试几次,以后就明白了。
Servlet基本上就是这样部署的,多试几次,以后就明白了。
#12
我已经重启了好几次了
没有用
不过非常感谢你,这么热心
没有用
不过非常感谢你,这么热心
#13
你的TechSupportServlet.java是怎么写的,如果有package name的话你应该这样部署:
例如你的TechSupportServlet.java 里有这样一句
package TechSupportServlet;
。。。。。
那么你的部署应该是这样的:
目录结构:
%tomcat_home%\webapps\tech-support\WEB-INF\classes\TechSupportServlet\TechSupportServlet.class
web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet.TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>
</servlet-mapping>
</web-app>
best regards!
例如你的TechSupportServlet.java 里有这样一句
package TechSupportServlet;
。。。。。
那么你的部署应该是这样的:
目录结构:
%tomcat_home%\webapps\tech-support\WEB-INF\classes\TechSupportServlet\TechSupportServlet.class
web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet.TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>
</servlet-mapping>
</web-app>
best regards!
#14
另外你在看看你的doPost()方法是否已经实现.
#15
1. don't deploy servlet without package
2. action="action" avoid using "/"
3. carefully study the examples on tomcat5.0
2. action="action" avoid using "/"
3. carefully study the examples on tomcat5.0
#16
楼主你把
<?xml version="1.0" encoding="ISO-8859-1"?>
换成
<?xml version="1.0" encoding="UTF-8"?>
这样试用一下
其它得不用改
<?xml version="1.0" encoding="ISO-8859-1"?>
换成
<?xml version="1.0" encoding="UTF-8"?>
这样试用一下
其它得不用改
#17
下面是TechSupportServlet.java的主要代码:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.sql.*;
import javax.sql.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class TechSupportServlet extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
//数据库连接参数
String protocol;
String user;
String password;
//初始化数据库连接协议
public void init() throws ServletException {
String driver = getServletConfig().getInitParameter("driver");
protocol = getServletConfig().getInitParameter("protocol");
user = getServletConfig().getInitParameter("user");
password = getServletConfig().getInitParameter("password");
if (driver == null || protocol == null) {
throw new UnavailableException("Driver not specified.");
}
try {
Class.forName(driver);
} catch (ClassNotFoundException cnfe) {
throw new UnavailableException("Driver <" + driver
+ "> not found in the classpath.");
}
}
//Process the HTTP Post request
public void doPost(HttpServletRequest req,HttpServletResponse response) throws ServletException, IOException {
//读取用户输入/选择
String firstName = req.getParameter("firstName");
String lastName = req.getParameter("lastName");
String email = req.getParameter("email");
String phone = req.getParameter("phone");
String software = req.getParameter("software");
String os = req.getParameter("os");
String problem = req.getParameter("problem");
//更新数据库
int requestId = 0;
Connection connection = null;
String insertStatementStr =
"INSERT INTO SUPP_REQUESTS VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
try {
//connection = DriverManager.getConnection(protocol);
connection = DbConnection.getConnection(protocol,user,password);
PreparedStatement insertStatement =
connection.prepareStatement(insertStatementStr);
requestId = Sequencer.getNextNumber(protocol,user,password);
insertStatement.setInt(1, requestId);
insertStatement.setString(2, firstName);
insertStatement.setString(3, lastName);
insertStatement.setString(4, email);
insertStatement.setString(5, phone);
insertStatement.setString(6, software);
insertStatement.setString(7, os);
insertStatement.setString(8, problem);
insertStatement.executeUpdate();
} catch (SQLException sqle) {
throw new ServletException("Database error", sqle);
}
finally {
if (connection != null) {
try {
connection.close();
}
catch (SQLException sqle) { }
}
}
//产生应答页面
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println("Tech Support: Request Confirmation");
out.println("</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H1>Tech Support: Request Confirmation</H1>");
out.println("<P>Thank you for your request. Your request with the following reference number has been received.</P>");
out.println("<P>Request Reference: " + requestId + "</P>");
out.println("<P>Please note this number for future references.</P>");
out.println("<P>Your request will be attended to within 24 hours.</P>");
out.println("<P>Administrator <br>Techsupport team. </P>");
out.println("</BODY></HTML>");
out.close();
}
//Clean up resources
public void destroy() {
}
}
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.sql.*;
import javax.sql.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class TechSupportServlet extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
//数据库连接参数
String protocol;
String user;
String password;
//初始化数据库连接协议
public void init() throws ServletException {
String driver = getServletConfig().getInitParameter("driver");
protocol = getServletConfig().getInitParameter("protocol");
user = getServletConfig().getInitParameter("user");
password = getServletConfig().getInitParameter("password");
if (driver == null || protocol == null) {
throw new UnavailableException("Driver not specified.");
}
try {
Class.forName(driver);
} catch (ClassNotFoundException cnfe) {
throw new UnavailableException("Driver <" + driver
+ "> not found in the classpath.");
}
}
//Process the HTTP Post request
public void doPost(HttpServletRequest req,HttpServletResponse response) throws ServletException, IOException {
//读取用户输入/选择
String firstName = req.getParameter("firstName");
String lastName = req.getParameter("lastName");
String email = req.getParameter("email");
String phone = req.getParameter("phone");
String software = req.getParameter("software");
String os = req.getParameter("os");
String problem = req.getParameter("problem");
//更新数据库
int requestId = 0;
Connection connection = null;
String insertStatementStr =
"INSERT INTO SUPP_REQUESTS VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
try {
//connection = DriverManager.getConnection(protocol);
connection = DbConnection.getConnection(protocol,user,password);
PreparedStatement insertStatement =
connection.prepareStatement(insertStatementStr);
requestId = Sequencer.getNextNumber(protocol,user,password);
insertStatement.setInt(1, requestId);
insertStatement.setString(2, firstName);
insertStatement.setString(3, lastName);
insertStatement.setString(4, email);
insertStatement.setString(5, phone);
insertStatement.setString(6, software);
insertStatement.setString(7, os);
insertStatement.setString(8, problem);
insertStatement.executeUpdate();
} catch (SQLException sqle) {
throw new ServletException("Database error", sqle);
}
finally {
if (connection != null) {
try {
connection.close();
}
catch (SQLException sqle) { }
}
}
//产生应答页面
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println("Tech Support: Request Confirmation");
out.println("</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H1>Tech Support: Request Confirmation</H1>");
out.println("<P>Thank you for your request. Your request with the following reference number has been received.</P>");
out.println("<P>Request Reference: " + requestId + "</P>");
out.println("<P>Please note this number for future references.</P>");
out.println("<P>Your request will be attended to within 24 hours.</P>");
out.println("<P>Administrator <br>Techsupport team. </P>");
out.println("</BODY></HTML>");
out.close();
}
//Clean up resources
public void destroy() {
}
}
#18
to hiking:
我不同意你的第一点
因为我看了Tomcat5的servlet-examples
里面有一个HelloWorldExample.java
他就是不在任何包内
我不同意你的第一点
因为我看了Tomcat5的servlet-examples
里面有一个HelloWorldExample.java
他就是不在任何包内
#19
to xinshou1979330:
您的方法,我也尝试了,不行。
下面是主要设置:
index.html:
<FORM ACTION="servlet/TechSupportServlet" METHOD="POST">
web.xml(我这是按照Tomcat里面自带实例做的配置):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TechSupportServlet</servlet-name>
<url-pattern>/servlet/TechSupportServlet</url-pattern>
</servlet-mapping>
</web-app>
您的方法,我也尝试了,不行。
下面是主要设置:
index.html:
<FORM ACTION="servlet/TechSupportServlet" METHOD="POST">
web.xml(我这是按照Tomcat里面自带实例做的配置):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TechSupportServlet</servlet-name>
<url-pattern>/servlet/TechSupportServlet</url-pattern>
</servlet-mapping>
</web-app>
#20
回复人: EricHxy(龙真) ( ) 信誉:100
to hiking:
我不同意你的第一点
因为我看了Tomcat5的servlet-examples
里面有一个HelloWorldExample.java
他就是不在任何包内
===============================================================
没关系,这只是多次莫名其妙的失败中获得的。
理论上说,你可以把<url-pattern>/servlet/TechSupportServlet</url-pattern>中的/servlet/TechSupportServlet直接敲在IE中如:http://localhost:8080/yourwebapp/servlet/TechSupportServlet
有结果就对了,没有就有问题。
然后,还是要把servlet放在包中。
to hiking:
我不同意你的第一点
因为我看了Tomcat5的servlet-examples
里面有一个HelloWorldExample.java
他就是不在任何包内
===============================================================
没关系,这只是多次莫名其妙的失败中获得的。
理论上说,你可以把<url-pattern>/servlet/TechSupportServlet</url-pattern>中的/servlet/TechSupportServlet直接敲在IE中如:http://localhost:8080/yourwebapp/servlet/TechSupportServlet
有结果就对了,没有就有问题。
然后,还是要把servlet放在包中。
#21
to hiking:
我在IE中敲入:
http://localhost:8080/servlets-examples/servlet/HelloWorldExample
他的就是能够找到呢?
我看了代码,这个servlet也不在任何包里面啊?
我在IE中敲入:
http://localhost:8080/servlets-examples/servlet/HelloWorldExample
他的就是能够找到呢?
我看了代码,这个servlet也不在任何包里面啊?
#22
to hiking:
不管怎样,今天我就按照你的办法,加到包里面试试看
谢谢你
不管怎样,今天我就按照你的办法,加到包里面试试看
谢谢你
#23
搞不定,今天晚上散分
郁闷
郁闷
#24
给大家推荐个好网站
http://www.djtz.net/get.asp?get=9662
http://www.djtz.net/get.asp?get=9662
#25
你的代码没有问题
首先确定你的serlet是不是放在web-inf/classes目录下
再看看你的web-inf是不是放在工作目录下,我的意思是必须放在工作目录下
比如你的工作目录是d:\jsp 那你就不能放到d:\jsp\serlet下,我用javabean时碰到过这中问题,再试试看,我不敢保证一定没有问题哦!
首先确定你的serlet是不是放在web-inf/classes目录下
再看看你的web-inf是不是放在工作目录下,我的意思是必须放在工作目录下
比如你的工作目录是d:\jsp 那你就不能放到d:\jsp\serlet下,我用javabean时碰到过这中问题,再试试看,我不敢保证一定没有问题哦!
#1
楼主,请详细说明一下,你的类文件是如何放的,应该放到 web-inf/classes的文件下
#2
楼上讲的是一点
另外地址栏中url注意,尤其是端口。。
另外地址栏中url注意,尤其是端口。。
#3
下面是我的目录结构:
%tomcat_home%\webapps\tech-support\index.html
%tomcat_home%\webapps\tech-support\WEB-INF\web.xml
%tomcat_home%\webapps\tech-support\WEB-INF\classes\DbConnection.class
%tomcat_home%\webapps\tech-support\WEB-INF\classes\Sequencer.class
%tomcat_home%\webapps\tech-support\WEB-INF\classes\TechSupportServlet.class
下面是web.xml的内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet Learning</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
</web-app>
请高手帮我看看,谢谢了。
%tomcat_home%\webapps\tech-support\index.html
%tomcat_home%\webapps\tech-support\WEB-INF\web.xml
%tomcat_home%\webapps\tech-support\WEB-INF\classes\DbConnection.class
%tomcat_home%\webapps\tech-support\WEB-INF\classes\Sequencer.class
%tomcat_home%\webapps\tech-support\WEB-INF\classes\TechSupportServlet.class
下面是web.xml的内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet Learning</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
</web-app>
请高手帮我看看,谢谢了。
#4
真的是郁闷,这么简单都搞不定
#5
我认为还是web.xml的问题
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet Learning</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
</web-app>
<servlet-mapping>
<servlet-name>TechSupportServlet</servlet-name>
<url-pattern>/TechSupportServlet</url-pattern> //请注意这里是否设置正确了,
//另外注意Jsp页面中调 //这个servlet时大小写是否一致
</servlet-mapping>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet Learning</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
</web-app>
<servlet-mapping>
<servlet-name>TechSupportServlet</servlet-name>
<url-pattern>/TechSupportServlet</url-pattern> //请注意这里是否设置正确了,
//另外注意Jsp页面中调 //这个servlet时大小写是否一致
</servlet-mapping>
#6
调用servlet的时候,action="/techSupportServlet"
action后面的是<url-pattern>/TechSupportServlet</url-pattern>中的部分,T小写
action后面的是<url-pattern>/TechSupportServlet</url-pattern>中的部分,T小写
#7
web.xml内容改成如下试试
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>//这是在浏览时的url
</servlet-mapping>
</web-app>
然后在提交时提交到http://localhost:8080/tech
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>//这是在浏览时的url
</servlet-mapping>
</web-app>
然后在提交时提交到http://localhost:8080/tech
#8
各位老大的方法我都一一试过了,奇迹没有出现,还是老样子。
CoolAbu,我在HTML页面中是这样写的:
<FORM ACTION="/tech" METHOD="POST">
可是还是报错:
HTTP Status 404 - /tech
--------------------------------------------------------------------------------
type Status report
message /tech
description The requested resource (/tech) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.19
CoolAbu,我在HTML页面中是这样写的:
<FORM ACTION="/tech" METHOD="POST">
可是还是报错:
HTTP Status 404 - /tech
--------------------------------------------------------------------------------
type Status report
message /tech
description The requested resource (/tech) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.19
#9
下面是我的HTML页面代码:
<HTML>
<HEAD>
<TITLE>XYZ Corporation, IT Department</title>
</HEAD>
<BODY>
<H1>Technical Support Request</H1>
<HR><BR>
<CENTER>
<FORM ACTION="/tech" METHOD="POST">
<TABLE ALIGN="center" WIDTH="100%" CELLSPACING="2" CELLPADDING="2">
<TR>
<TD ALIGN="right">First Name:</TD>
<TD><INPUT TYPE="Text" NAME="firstName" ALIGN="LEFT" SIZE="15"></TD>
<TD ALIGN="right">Last Name:</TD>
<TD><INPUT TYPE="Text" NAME="lastName" ALIGN="LEFT" SIZE="15"></TD>
</TR>
<TR>
<TD ALIGN="right">Email:</TD>
<TD><INPUT TYPE="Text" NAME="email" ALIGN="LEFT" SIZE="25"></TD>
<TD ALIGN="right">Phone:</TD>
<TD><INPUT TYPE="Text" NAME="phone" ALIGN="LEFT" SIZE="15"></TD>
</TR>
<TR>
<TD ALIGN="right">Software:</TD>
<TD>
<SELECT NAME="software" SIZE="1">
<OPTION VALUE="Word">Microsoft Word</OPTION>
<OPTION VALUE="Excel">Microsoft Excel</OPTION>
<OPTION VALUE="Access">Microsoft Access</OPTION>
</SELECT>
</TD>
<TD ALIGN="right">Operating System:</TD>
<TD>
<SELECT NAME="os" size="1">
<OPTION VALUE="95">Windows 95</OPTION>
<OPTION VALUE="98">Windows 98</OPTION>
<OPTION VALUE="NT">Windows NT</OPTION>
</SELECT>
</TD>
</TR>
</TABLE>
<BR>Problem Description
<BR>
<TEXTAREA NAME="problem" COLS="50" ROWS="4"></TEXTAREA>
<HR><BR>
<INPUT TYPE="Submit" NAME="submit" VALUE="Submit Request">
</FORM>
</CENTER>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>XYZ Corporation, IT Department</title>
</HEAD>
<BODY>
<H1>Technical Support Request</H1>
<HR><BR>
<CENTER>
<FORM ACTION="/tech" METHOD="POST">
<TABLE ALIGN="center" WIDTH="100%" CELLSPACING="2" CELLPADDING="2">
<TR>
<TD ALIGN="right">First Name:</TD>
<TD><INPUT TYPE="Text" NAME="firstName" ALIGN="LEFT" SIZE="15"></TD>
<TD ALIGN="right">Last Name:</TD>
<TD><INPUT TYPE="Text" NAME="lastName" ALIGN="LEFT" SIZE="15"></TD>
</TR>
<TR>
<TD ALIGN="right">Email:</TD>
<TD><INPUT TYPE="Text" NAME="email" ALIGN="LEFT" SIZE="25"></TD>
<TD ALIGN="right">Phone:</TD>
<TD><INPUT TYPE="Text" NAME="phone" ALIGN="LEFT" SIZE="15"></TD>
</TR>
<TR>
<TD ALIGN="right">Software:</TD>
<TD>
<SELECT NAME="software" SIZE="1">
<OPTION VALUE="Word">Microsoft Word</OPTION>
<OPTION VALUE="Excel">Microsoft Excel</OPTION>
<OPTION VALUE="Access">Microsoft Access</OPTION>
</SELECT>
</TD>
<TD ALIGN="right">Operating System:</TD>
<TD>
<SELECT NAME="os" size="1">
<OPTION VALUE="95">Windows 95</OPTION>
<OPTION VALUE="98">Windows 98</OPTION>
<OPTION VALUE="NT">Windows NT</OPTION>
</SELECT>
</TD>
</TR>
</TABLE>
<BR>Problem Description
<BR>
<TEXTAREA NAME="problem" COLS="50" ROWS="4"></TEXTAREA>
<HR><BR>
<INPUT TYPE="Submit" NAME="submit" VALUE="Submit Request">
</FORM>
</CENTER>
</BODY>
</HTML>
#10
下面是修改之后的web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>
</servlet-mapping>
</web-app>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>
</servlet-mapping>
</web-app>
#11
你把Tomcat重启一次,然后用下面这个试试http://locahost:8080/tech-support/tech
Servlet基本上就是这样部署的,多试几次,以后就明白了。
Servlet基本上就是这样部署的,多试几次,以后就明白了。
#12
我已经重启了好几次了
没有用
不过非常感谢你,这么热心
没有用
不过非常感谢你,这么热心
#13
你的TechSupportServlet.java是怎么写的,如果有package name的话你应该这样部署:
例如你的TechSupportServlet.java 里有这样一句
package TechSupportServlet;
。。。。。
那么你的部署应该是这样的:
目录结构:
%tomcat_home%\webapps\tech-support\WEB-INF\classes\TechSupportServlet\TechSupportServlet.class
web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet.TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>
</servlet-mapping>
</web-app>
best regards!
例如你的TechSupportServlet.java 里有这样一句
package TechSupportServlet;
。。。。。
那么你的部署应该是这样的:
目录结构:
%tomcat_home%\webapps\tech-support\WEB-INF\classes\TechSupportServlet\TechSupportServlet.class
web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>tech</servlet-name>
<servlet-class>TechSupportServlet.TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>tech</servlet-name>
<url-pattern>/tech</url-pattern>
</servlet-mapping>
</web-app>
best regards!
#14
另外你在看看你的doPost()方法是否已经实现.
#15
1. don't deploy servlet without package
2. action="action" avoid using "/"
3. carefully study the examples on tomcat5.0
2. action="action" avoid using "/"
3. carefully study the examples on tomcat5.0
#16
楼主你把
<?xml version="1.0" encoding="ISO-8859-1"?>
换成
<?xml version="1.0" encoding="UTF-8"?>
这样试用一下
其它得不用改
<?xml version="1.0" encoding="ISO-8859-1"?>
换成
<?xml version="1.0" encoding="UTF-8"?>
这样试用一下
其它得不用改
#17
下面是TechSupportServlet.java的主要代码:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.sql.*;
import javax.sql.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class TechSupportServlet extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
//数据库连接参数
String protocol;
String user;
String password;
//初始化数据库连接协议
public void init() throws ServletException {
String driver = getServletConfig().getInitParameter("driver");
protocol = getServletConfig().getInitParameter("protocol");
user = getServletConfig().getInitParameter("user");
password = getServletConfig().getInitParameter("password");
if (driver == null || protocol == null) {
throw new UnavailableException("Driver not specified.");
}
try {
Class.forName(driver);
} catch (ClassNotFoundException cnfe) {
throw new UnavailableException("Driver <" + driver
+ "> not found in the classpath.");
}
}
//Process the HTTP Post request
public void doPost(HttpServletRequest req,HttpServletResponse response) throws ServletException, IOException {
//读取用户输入/选择
String firstName = req.getParameter("firstName");
String lastName = req.getParameter("lastName");
String email = req.getParameter("email");
String phone = req.getParameter("phone");
String software = req.getParameter("software");
String os = req.getParameter("os");
String problem = req.getParameter("problem");
//更新数据库
int requestId = 0;
Connection connection = null;
String insertStatementStr =
"INSERT INTO SUPP_REQUESTS VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
try {
//connection = DriverManager.getConnection(protocol);
connection = DbConnection.getConnection(protocol,user,password);
PreparedStatement insertStatement =
connection.prepareStatement(insertStatementStr);
requestId = Sequencer.getNextNumber(protocol,user,password);
insertStatement.setInt(1, requestId);
insertStatement.setString(2, firstName);
insertStatement.setString(3, lastName);
insertStatement.setString(4, email);
insertStatement.setString(5, phone);
insertStatement.setString(6, software);
insertStatement.setString(7, os);
insertStatement.setString(8, problem);
insertStatement.executeUpdate();
} catch (SQLException sqle) {
throw new ServletException("Database error", sqle);
}
finally {
if (connection != null) {
try {
connection.close();
}
catch (SQLException sqle) { }
}
}
//产生应答页面
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println("Tech Support: Request Confirmation");
out.println("</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H1>Tech Support: Request Confirmation</H1>");
out.println("<P>Thank you for your request. Your request with the following reference number has been received.</P>");
out.println("<P>Request Reference: " + requestId + "</P>");
out.println("<P>Please note this number for future references.</P>");
out.println("<P>Your request will be attended to within 24 hours.</P>");
out.println("<P>Administrator <br>Techsupport team. </P>");
out.println("</BODY></HTML>");
out.close();
}
//Clean up resources
public void destroy() {
}
}
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;
import java.sql.*;
import javax.sql.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public class TechSupportServlet extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
//数据库连接参数
String protocol;
String user;
String password;
//初始化数据库连接协议
public void init() throws ServletException {
String driver = getServletConfig().getInitParameter("driver");
protocol = getServletConfig().getInitParameter("protocol");
user = getServletConfig().getInitParameter("user");
password = getServletConfig().getInitParameter("password");
if (driver == null || protocol == null) {
throw new UnavailableException("Driver not specified.");
}
try {
Class.forName(driver);
} catch (ClassNotFoundException cnfe) {
throw new UnavailableException("Driver <" + driver
+ "> not found in the classpath.");
}
}
//Process the HTTP Post request
public void doPost(HttpServletRequest req,HttpServletResponse response) throws ServletException, IOException {
//读取用户输入/选择
String firstName = req.getParameter("firstName");
String lastName = req.getParameter("lastName");
String email = req.getParameter("email");
String phone = req.getParameter("phone");
String software = req.getParameter("software");
String os = req.getParameter("os");
String problem = req.getParameter("problem");
//更新数据库
int requestId = 0;
Connection connection = null;
String insertStatementStr =
"INSERT INTO SUPP_REQUESTS VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
try {
//connection = DriverManager.getConnection(protocol);
connection = DbConnection.getConnection(protocol,user,password);
PreparedStatement insertStatement =
connection.prepareStatement(insertStatementStr);
requestId = Sequencer.getNextNumber(protocol,user,password);
insertStatement.setInt(1, requestId);
insertStatement.setString(2, firstName);
insertStatement.setString(3, lastName);
insertStatement.setString(4, email);
insertStatement.setString(5, phone);
insertStatement.setString(6, software);
insertStatement.setString(7, os);
insertStatement.setString(8, problem);
insertStatement.executeUpdate();
} catch (SQLException sqle) {
throw new ServletException("Database error", sqle);
}
finally {
if (connection != null) {
try {
connection.close();
}
catch (SQLException sqle) { }
}
}
//产生应答页面
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println("Tech Support: Request Confirmation");
out.println("</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H1>Tech Support: Request Confirmation</H1>");
out.println("<P>Thank you for your request. Your request with the following reference number has been received.</P>");
out.println("<P>Request Reference: " + requestId + "</P>");
out.println("<P>Please note this number for future references.</P>");
out.println("<P>Your request will be attended to within 24 hours.</P>");
out.println("<P>Administrator <br>Techsupport team. </P>");
out.println("</BODY></HTML>");
out.close();
}
//Clean up resources
public void destroy() {
}
}
#18
to hiking:
我不同意你的第一点
因为我看了Tomcat5的servlet-examples
里面有一个HelloWorldExample.java
他就是不在任何包内
我不同意你的第一点
因为我看了Tomcat5的servlet-examples
里面有一个HelloWorldExample.java
他就是不在任何包内
#19
to xinshou1979330:
您的方法,我也尝试了,不行。
下面是主要设置:
index.html:
<FORM ACTION="servlet/TechSupportServlet" METHOD="POST">
web.xml(我这是按照Tomcat里面自带实例做的配置):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TechSupportServlet</servlet-name>
<url-pattern>/servlet/TechSupportServlet</url-pattern>
</servlet-mapping>
</web-app>
您的方法,我也尝试了,不行。
下面是主要设置:
index.html:
<FORM ACTION="servlet/TechSupportServlet" METHOD="POST">
web.xml(我这是按照Tomcat里面自带实例做的配置):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>TechSupportServlet</servlet-name>
<servlet-class>TechSupportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TechSupportServlet</servlet-name>
<url-pattern>/servlet/TechSupportServlet</url-pattern>
</servlet-mapping>
</web-app>
#20
回复人: EricHxy(龙真) ( ) 信誉:100
to hiking:
我不同意你的第一点
因为我看了Tomcat5的servlet-examples
里面有一个HelloWorldExample.java
他就是不在任何包内
===============================================================
没关系,这只是多次莫名其妙的失败中获得的。
理论上说,你可以把<url-pattern>/servlet/TechSupportServlet</url-pattern>中的/servlet/TechSupportServlet直接敲在IE中如:http://localhost:8080/yourwebapp/servlet/TechSupportServlet
有结果就对了,没有就有问题。
然后,还是要把servlet放在包中。
to hiking:
我不同意你的第一点
因为我看了Tomcat5的servlet-examples
里面有一个HelloWorldExample.java
他就是不在任何包内
===============================================================
没关系,这只是多次莫名其妙的失败中获得的。
理论上说,你可以把<url-pattern>/servlet/TechSupportServlet</url-pattern>中的/servlet/TechSupportServlet直接敲在IE中如:http://localhost:8080/yourwebapp/servlet/TechSupportServlet
有结果就对了,没有就有问题。
然后,还是要把servlet放在包中。
#21
to hiking:
我在IE中敲入:
http://localhost:8080/servlets-examples/servlet/HelloWorldExample
他的就是能够找到呢?
我看了代码,这个servlet也不在任何包里面啊?
我在IE中敲入:
http://localhost:8080/servlets-examples/servlet/HelloWorldExample
他的就是能够找到呢?
我看了代码,这个servlet也不在任何包里面啊?
#22
to hiking:
不管怎样,今天我就按照你的办法,加到包里面试试看
谢谢你
不管怎样,今天我就按照你的办法,加到包里面试试看
谢谢你
#23
搞不定,今天晚上散分
郁闷
郁闷
#24
给大家推荐个好网站
http://www.djtz.net/get.asp?get=9662
http://www.djtz.net/get.asp?get=9662
#25
你的代码没有问题
首先确定你的serlet是不是放在web-inf/classes目录下
再看看你的web-inf是不是放在工作目录下,我的意思是必须放在工作目录下
比如你的工作目录是d:\jsp 那你就不能放到d:\jsp\serlet下,我用javabean时碰到过这中问题,再试试看,我不敢保证一定没有问题哦!
首先确定你的serlet是不是放在web-inf/classes目录下
再看看你的web-inf是不是放在工作目录下,我的意思是必须放在工作目录下
比如你的工作目录是d:\jsp 那你就不能放到d:\jsp\serlet下,我用javabean时碰到过这中问题,再试试看,我不敢保证一定没有问题哦!