我有一个 servlet 用作我的网络应用程序的欢迎文件。当我只输入上下文根时调用这个 servlet 时,有没有办法可以调用 servlet 的 doPOST 方法?
网页.xml:
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/mainPage</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>mainPage</welcome-file>
</welcome-file-list>
MyServlet.Java:
public class MyServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("GET");
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("POST");
}
}
假设我的上下文根是 MyApp,有没有办法,我可以通过调用 http://[host]:[port]/MyApp 来打印 POST ?
问候,赫曼