문제점 : doPost를 호출 할 때 doGet 만 호출됩니다.Embedded Jetty doGet 호출, 예상 doPost
나는으로 시작 내장 제티 서버는 다음과 같습니다
server = new Server(8080);
ServletContextHandler myContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
myContext.setContextPath("/Test.do");
myContext.addServlet(new ServletHolder(new MyServlet()), "/*");
ResourceHandler rh = new ResourceHandler();
rh.setResrouceBase("C:\\public");
HandlerList hl = new HandlerList();
hl.setHandlers(new Handler[]{rh, myContext});
server.setHandler(hl);
//server.start() follows
내가 서버를 시작하면, 내가 ("공개"폴더에있는, 그리고 http://localhost:8080/test.html를 통해 열)는 다음 페이지를 엽니 다
<html>
<head><title>Test Page</title></head>
<body>
<p>Test for Post.</p>
<form method="POST" action="Test.do"/>
<input name="field" type="text" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
제출 버튼을 누르면 서블릿의 doPost 메소드가 호출 될 것으로 예상되지만 doGet이 호출되는 것으로 보입니다. MyServlet이라는 클래스 (확장 HttpServlet을) 포함
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
System.out.println(" doGet called with URI: " + request.getRequestURI());
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
System.out.println(" doPost called with URI: " + request.getRequestURI());
}
나는 결코 (버튼을 눌러 제출에 있음)의 doPost 인쇄,의 doGet에서 단지 하나를 얻을.
명백하게, 부두 (및 웹 기술 일반적으로)는 저에게 아주 새로운 것입니다. Jetty 예제를 샅샅이 살펴 보았지만 실제로 doPost 메서드로 POST를 가져 오지 못하는 것 같습니다.
감사합니다. 미리 감사드립니다.