如何刷新静态文件,如TomCat中的html / css(嵌入式)?无需重启服务器。 InelliJ Idea。通过使用某种配置
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();
}
}