JSP 页面在 Jrun 中正常工作,但是当我使用 servlet 时,它找不到该 servlet 的 .class 文件,并在执行时出现 404 错误。谁能帮助我 jrun 如何与 servlet 一起工作?我错过了什么吗?
这是我的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>myProject</display-name>
<servlet>
<description></description>
<display-name>myClass</display-name>
<servlet-name>myClass</servlet-name>
<servlet-class>myPackage.myClass</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myClass</servlet-name>
<url-pattern>/myClass</url-pattern>
</servlet-mapping>
</web-app>
和我的简单 servlet
package myPackage;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
public class myClass extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter pw = response.getWriter();
pw.println("<html><body>my page</body></html>");
}
}
和jsp页面
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="myClass" method="post">
<input type="submit" value="submit">
</form>
</body>
</html>