如何刷新静态文件,例如 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(嵌入),无需重启即可进行更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49721383/