Java---@WebServlet注解的使用

时间:2016-05-28 10:11:32   收藏:0   阅读:1930

1、tomcat7.0以后的版本才可以使用@WebServlet注解

2、要引入tomcat目录下lib中的servlet-api.jar包。(“Build Path”->“Add External Archives”)

3、导入包 :import javax.servlet.annotation.WebServlet;

4、使用@WebServlet

@WebServlet(urlPatterns={"/currtime"})
public class CurrTimeServlet extends HttpServlet {
....
}

5、运行
http://localhost:8080/hello/currtime

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!