Skip to content

Commit

Permalink
small modify
Browse files Browse the repository at this point in the history
  • Loading branch information
tywo45 committed Oct 5, 2019
1 parent cb2e91e commit 2f43609
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ recommend that a file or class name and description of purpose be included on
*
*/
public class ShortMessageTemplateExceptionHandler implements TemplateExceptionHandler {
private static Logger log = LoggerFactory.getLogger(ShortMessageTemplateExceptionHandler.class);
public static ShortMessageTemplateExceptionHandler me = new ShortMessageTemplateExceptionHandler();
private static Logger log = LoggerFactory.getLogger(ShortMessageTemplateExceptionHandler.class);
public final static ShortMessageTemplateExceptionHandler me = new ShortMessageTemplateExceptionHandler();

@Override
public void handleTemplateException(TemplateException templateexception, Environment environment, Writer writer) throws TemplateException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,14 @@ private Configuration createConfiguration(HttpConfig httpConfig, String root) th
} else {
cfg.setDirectoryForTemplateLoading(new File(root));
}

cfg.setDefaultEncoding(httpConfig.getCharset());
// cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
cfg.setLogTemplateExceptions(false);
cfg.setWrapUncheckedExceptions(true);
cfg.setTemplateExceptionHandler(ShortMessageTemplateExceptionHandler.me);
cfg.setLocale(Locale.SIMPLIFIED_CHINESE);
cfg.setNumberFormat("#");
cfg.setClassicCompatible(true);
return cfg;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ public HttpResponse handler(HttpRequest request) throws Exception {
String retStr = FreemarkerUtils.generateStringByPath(template, configuration, model);
response = Resps.bytes(request, retStr.getBytes(configuration.getDefaultEncoding()), extension);
return response;
} catch (Exception e) {
} catch (Throwable e) {
log.error("freemarker错误,当成普通文本处理:" + file.getCanonicalPath() + ", " + e.toString());
}
}
Expand Down

0 comments on commit 2f43609

Please sign in to comment.