使用Eclipse的New-> Servlet向导,从而为我准备好自动生成的servlet和servlet-mapping条目。但是当我选择一个servlet的java文件并将其删除时,web.xml中的相应条目不会被删除。
我该怎么做?
答案 0 :(得分:2)
我想象一下编辑web.xml
文件并删除条目。根据设计,删除servlet时不会自动删除它们。
答案 1 :(得分:0)
如何使用Annotations?您不必为此在web.xml中处理任何配置。
package com.inventwheel.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class DeleteMe
*/
@WebServlet(description = "DeleteMe Servlet", urlPatterns = { "/DeleteMe" })
public class DeleteMe extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public DeleteMe() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
}