更新时间:2022-03-18 23:17:20
试试这个(如果Java EE V6)
try this (if the Java EE V6)
package crunch;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
@WebServlet(name="hello",urlPatterns={"/hello"})
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}
现在达到通过 http://127.0.0.1:8080/yourapp/hello
其中8080为默认的Tomcat端口,yourapp是你applciation的上下文名称
where 8080 is default tomcat port, and yourapp is the context name of your applciation