Handling file not found on ftl page in Freemarker
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.
精彩评论