如题,第一次用myeclipse 就出问题了,唉、、、
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class ServletDemo1 extends GenericServlet{
@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
OutputStream out = res.getOutputStream();
out.write("Servlet!!!!".getBytes());
}
}[/code]
这是Java代码、、、
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>ServletDemo1</servlet-name>
<servlet-class>/Web_Servlet/src/com/fox/ServletDemo1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletDemo1</servlet-name>
<url-pattern>/ServletDemo1</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
这是配置文件,好了,然后我把server启动,在IE里面访问http://localhost:8080/Web_Servlet/ServletDemo1就出问题了。
首先,ie里面显示500错误,服务器那段抛出java.lang.ClassNotFoundException: /Web_Servlet/src/com/fox/ServletDemo1这个异常、、、
百度了好多,实在搞不明白,求大神啊!!!!!!
------解决思路----------------------
<servlet>
<servlet-name>ServletDemo1</servlet-name>
<servlet-class>/Web_Servlet/src/com/fox/ServletDemo1</servlet-class>
</servlet>
红色部分是JAVA类,正确应该是:
<servlet>
<servlet-name>ServletDemo1</servlet-name>
<servlet-class>com.fox.ServletDemo1</servlet-class>
</servlet>