import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(urlPatterns = "/")
public class MyServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().append("get req");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().append("post req");
}
}
springboot框架建了个1个Servlet , 匹配路径"/", 用 http://127.0.0.1:8080/abc , 访问报错404; 改为 "/*" 可以,
请问为何用默认路径"/",无法访问?