Tomcat7 アノテーションをつかったサーブレットの登録

tomcat7あたりからweb.xmlでのサーブレットの登録は
アノテーションって仕組みをつかえばスキップできる
とのことなので、以下実例
(というか、eclipseの吐いたコードをほとんどそのままこぴぺw)

アノテーションの部分は

@WebServlet("/HelloServlet")

これだけ

[root@localhost WEB-INF]# pwd
/usr/local/tomcat/webapps/006/WEB-INF

[root@localhost WEB-INF]# ls -ltr
合計 12
drwxr-xr-x. 2 root root 4096  5月 12 13:06 2013 lib
-rw-r--r--. 1 root root  697  5月 12 13:10 2013 web.xml
drwxr-xr-x. 3 root root 4096  5月 12 18:34 2013 classes
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# find .
.
./lib
./web.xml
./classes
./classes/hirasawa
./classes/hirasawa/HelloServlet.class
./classes/hirasawa/HelloServlet.java
[root@localhost WEB-INF]# pwd
/usr/local/tomcat/webapps/006/WEB-INF
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# cat 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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>006</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# 
[root@localhost WEB-INF]# cd classes/hirasawa/
[root@localhost hirasawa]# ls -ltr
合計 8
-rw-r--r--. 1 root root 1265  5月 12 14:34 2013 HelloServlet.java
-rw-r--r--. 1 root root 1242  5月 12 14:34 2013 HelloServlet.class
[root@localhost hirasawa]# cat HelloServlet.java 
package hirasawa;

import java.io.*;
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 HelloServlet
 */
@WebServlet("/HelloServlet")
public class HelloServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HelloServlet() {
        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
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("HelloWorld");
out.println("</html>");
out.close();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}


}
[root@localhost hirasawa]#