简体   繁体   English

码头:HelloWorld示例无法更改内容

[英]Jetty: HelloWorld example cannot change content

I'm new to Jetty, and I tried to run the example for "HelloWorld" 我是Jetty的新手,我尝试为“ HelloWorld”运行示例

public class HelloWorld extends AbstractHandler
{
    public void handle(String target,
                       Request baseRequest,
                       HttpServletRequest request,
                       HttpServletResponse response) 
        throws IOException, ServletException
    {
        response.setContentType("text/html;charset=utf-8");
        response.setStatus(HttpServletResponse.SC_OK);
        baseRequest.setHandled(true);
        response.getWriter().println("<h1>Hello World</h1>");
    }

    public static void main(String[] args) throws Exception
    {
        Server server = new Server(8080);
        server.setHandler(new HelloWorld());

        server.start();
        server.join();
    }
}

and the "Hello World" does shows on the JSP page in my localhost:8080. 并且“ Hello World”确实显示在我的localhost:8080的JSP页面上。 But I'm not able to change any content inside, or even stop the server. 但是我无法更改其中的任何内容,甚至无法停止服务器。 What can I do with this? 我该怎么办?

Since you do a join() at the end, your only way to stop the server is to kill it. 由于您在最后执行了join(),因此停止服务器的唯一方法是将其杀死。 If you haven't succeed in stopping your server, how can you say that you cannot change the content? 如果您未能成功停止服务器,那么如何说不能更改内容呢?

I solve the problem. 我解决了问题。 Cuz I run it in my eclipse, so I need to stop the server that created from eclipse, and the only way to kill the server is go to the tast manager, and end all the java program. 因为我在eclipse中运行它,所以我需要停止从eclipse创建的服务器,杀死该服务器的唯一方法是转到tast管理器,并结束所有java程序。 thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM