@WebServlet("/LoginServlet")
jsp页面: <form action="LoginServlet" method = "post"> java类: @WebServlet("/LoginServlet") public class Login extends HttpServlet {}
等价于在web.xml配置
<servlet> <!-- 类名 --> <servlet-name>Login</servlet-name> <!-- 所在的包 --> <servlet-class>com.servlet.Login</servlet-class> </servlet> <servlet-mapping> <servlet-name>Login</servlet-name> <!-- 访问的网址 --> <url-pattern>/LoginServlet</url-pattern> </servlet-mapping>
@WebServlet可以在eclipse中servlet新建生成