开发者

Handling file not found on ftl page in Freemarker

开发者 https://www.devze.com 2023-03-29 14:31 出处:网络
How开发者_运维百科 can we handle the file not found exception on fileName.ftl file? So many have explained handling it on the action servlets. But I am not using any action servlet to load the freemar

How开发者_运维百科 can we handle the file not found exception on fileName.ftl file? So many have explained handling it on the action servlets. But I am not using any action servlet to load the freemarker. So no other option and I have to find a way to handle it on the template file itself..!


If the FileNotFoundException occurs during a FTL <#import> or <#include> inside your "main" FTL template, then I think you can catch the exception with FTL's attempt-recover-construct (similar to Java's try-catch). But if your "main" template cannot be found, then something outside of FreeMarker (e.g. the servlet which invoked FreeMarker) has to deal with it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号