

创建项目
勾选Web Application
勾选【JavaEE Application】
名字不是主要的
项目结构:
创建一个测试的【servlet】
package com.item.servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(“/GetInfo”)
public class GetInfoServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println(“success”);
}
}
项目结构
添加war包
改成根路径
访问完有显示,说明成功。
暂无评论内容