Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java jetty如何自动重新加载静态资源(html、css、jss)_Java_Spring_Jetty - Fatal编程技术网

Java jetty如何自动重新加载静态资源(html、css、jss)

Java jetty如何自动重新加载静态资源(html、css、jss),java,spring,jetty,Java,Spring,Jetty,我只是使用jetty为我的web项目提供服务,而不使用任何XML,但它仍然没有自动重新加载我设置的事件contextHandler.getInitParams().put(“org.eclipse.jetty.servlet.Default.useFileMappedBuffer”,“false”) PS:我的jetty是9.2版,我使用springmvc作为contextHandler,我在网站上尝试了很多方法和答案,比如https://gist.github.com/raymyers/532

我只是使用jetty为我的web项目提供服务,而不使用任何XML,但它仍然没有自动重新加载我设置的事件
contextHandler.getInitParams().put(“org.eclipse.jetty.servlet.Default.useFileMappedBuffer”,“false”)

PS:我的jetty是9.2版,我使用springmvc作为contextHandler,我在网站上尝试了很多方法和答案,比如
https://gist.github.com/raymyers/5323304
http://stackoverflow.com/questions/184312/how-to-make-jetty-dynamically-load-static-pages
,但仍然无法工作,我将等待解决方案

private void startJetty(int port) throws Exception {
    logger.debug("Starting server at port {}", port);
    Server server = new Server(port);
    server.setHandler(getServletContextHandler(getContext()));
    server.start();
    logger.info("Server started at port {}", port);
    server.join();
}

private static ServletContextHandler getServletContextHandler(WebApplicationContext context) throws Exception {
    WebAppContext contextHandler = new WebAppContext();
    contextHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
    contextHandler.getInitParams().put("cacheContro", "max-age=0, public");

    contextHandler.setErrorHandler(null);
    contextHandler.setContextPath(CONTEXT_PATH);
    contextHandler.addServlet(new ServletHolder(new DispatcherServlet(context)), MAPPING_URL);
    contextHandler.addEventListener(new ContextLoaderListener(context));
    contextHandler.setResourceBase(new ClassPathResource("static").getURI().toString());
    return contextHandler;
}

private static WebApplicationContext getContext() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation(CONFIG_LOCATION);
    context.getEnvironment().setDefaultProfiles(DEFAULT_PROFILE);
    return context;
}