idea配置tomcat必坑指南

2022-11-29 21:25:18 浏览数 (3)

创建项目

勾选Web Application

勾选【JavaEE Application】 

名字不是主要的

 项目结构:

创建一个测试的【servlet】

代码语言:javascript复制
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包

改成根路径 

 访问完有显示,说明成功。

0 人点赞