drogatkin / TJWS2

Tiny Java Web and App server second generation
66 stars 42 forks source link

servlet invoked twice when use wildcard /* #5

Open alexmao86 opened 7 years ago

alexmao86 commented 7 years ago

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