1、安装eclipse
2、Help -->> Install New Software,添加Apache tomcat相关插件
3、Windows -->> Preference -->> Server,选择Apache tomcat作为Server Runtime Env
4、File -->> New -->> Other,创建Java Web项目,选择生成web.xml文件。
5、添加Jsp文件以及Servlet文件,并配置Servlet与路径的映像关系。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>HelloServlet</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>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>demo.takchi.chan.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JsonServlet</servlet-name>
<servlet-class>demo.takchi.chan.JsonServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>JsonServlet</servlet-name>
<url-pattern>/HelloJson</url-pattern>
</servlet-mapping>
</web-app>
6、右键Run As -->> Run On Server,选择Apache tomcat
7、或者输出为war包,放到Apache tomcat安装目录下的webapps,启动时tomcat会自动解压。