【问题标题】:Tomcat (embeded), make changes without restartTomcat(嵌入式),无需重启即可进行更改
【发布时间】:2018-09-18 04:04:21
【问题描述】:

如何刷新静态文件,例如 TomCat(嵌入式)中的 html/css?无需重启服务器。 InelliJ 想法。通过使用某种配置

public class TomStart {
    public static void main(String[] args) throws LifecycleException,
            InterruptedException, ServletException {

        Tomcat tomcat = new Tomcat();
        tomcat.setPort(8082);
        tomcat.addContext("/", "/web");
        Context ctx = tomcat.addContext("/", new File(".").getAbsolutePath());

        Tomcat.addServlet(ctx, "Embedded", new HttpServlet() {
            @Override
            protected void service(HttpServletRequest req, HttpServletResponse resp)
                    throws ServletException, IOException {

                Writer w = resp.getWriter();
                w.write("Embedded Tomcat servlet.\n");
                w.flush();
                w.close();
            }
        });

        ctx.addServletMappingDecoded("/*", "Embedded");

        tomcat.start();
        tomcat.getServer().await();
    }

}

【问题讨论】:

标签: java tomcat refresh


【解决方案1】:
猜你喜欢
  • 2020-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多