TJWS2
TJWS2 copied to clipboard
servlet invoked twice when use wildcard /*
public class MainTest { public static void main(String[] args) { final Serve srv = new Serve(); java.util.Properties properties = new java.util.Properties(); properties.put("port", 80); properties.setProperty(com.koogu.server.Serve.ARG_NOHUP, "nohup");
//properties.setProperty("acceptorImpl", "Acme.Serve.SelectorAcceptor"); // this acceptor is requireed for websocket support.
srv.arguments = properties;
srv.addServlet("/*", new HttpServlet() {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("test="+req.getParameter("test"));
}
}, null); // optional
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
srv.notifyStop();
srv.destroyAllServlets();
}
}));
srv.serve();
}
}
then doGet was invoked twice: URL: http://localhost/a?test=123 output as: test=123 test=null