2019-05-08 09:15
@localhost8080
很明显是 target/classes/static/index/index.html 找不到,如果是打包后的,则在 jar 包中找不到 static/index/index.html
仔细看文档,有关 Engine 的从 class path 加载模板部分
一定要注意下面的两个配置与 undertow.resourcePath 配置完全无关:
engine.setToClassPathFactory();
engine.setBaseTemplatePath(basePath);
2019-05-07 19:51
@localhost8080 undertow.resourcePath 是配置 undertow 访问静态资源的方式,以 classpath: 打头是从 class path 和 jar 包中读静态资源
而 engine.setToClassPathFactory() 是指示 enjoy 模板引擎从 class path 和 jar 包中读模板文件
注意区分上面两者,它们两者完全无关,所以配置的时候不要将两者混在一起考虑
另一个知识是:将资源放入 src/main/resources 下面,会被 eclipse 、IDEA 自动 copy 到 class path 下面,也就是 target/classes 下面
所以,你可以将 src/main/resources 也当成是 class path来使用,进而 可以配置:
engine.setToClassPathFactory();
engine.setBaseTemplatePath(basePath);
其中 basePath 是资源文件在 src/main/resources 下面的子目录,一般是 static 或者 webapp,要根据实际情况去配置
2019-05-07 16:24
@tuxming web.xml 中没有配置,明显是这个错误引发的
2019-05-07 16:24
@tuxming 这种问题很好定位,java 的 web 组件可以监听 session 的创建、消毁,多搜索下资料,或许添加个 Listener ,打打断点即可
2019-05-07 16:06
@孤傲苍狼 classpath:... 这种配置在文档中都有, jfinal undertow 的文档极少,一定要仔细看完