It's me again :(
Now I crushed into some problems.
I am learning Servlet these day with IDEA.
I've written the code and configured Tomcat(version 10.0.10) like:
package yj.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(urlPatterns = {"/user"})
public class UserServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("来了个get请求");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("来了个post请求");
doGet(req, resp);
}
}
and
and to make sure, my Servlet version here
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
also my web-app version is 3.1(which might mean @WebServlet() is allowed to use)
I think there should be something printed in tomcat's output, like:
But this page shows up:
when I typed http://localhost:8089/user as address
so is there anything wrong with my servlet and how can I do this ..
Any help will be appreciated!
Project Structure is simple here.