我看这里的步骤进行集成:
https://github.com/nutzam/nutzmore/tree/master/nutz-plugins-views
MainModule:
@Modules(scanPackage = true)
@SetupBy(MySetup.class)
@Encoding(input = "UTF-8", output = "UTF-8")
@IocBy(type = ComboIocProvider.class,
args = {"*js", "ioc/", "*anno", "com.dd","*org.nutz.plugins.view.freemarker.FreemarkerIocLoader"})
//@Views(DDView.class)
@Views(FreemarkerViewMaker.class)
@Fail("json")
public class MainModule {
}
controller:
@At
@Ok("fm")
public Object hello(){
return new NutMap().setv("hello","world");
}
报错了:
[WARN ] 14:19:57.594 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) - Error@/user/hello :
java.lang.NullPointerException
at org.nutz.plugins.view.freemarker.FreemarkerView.getPath(FreemarkerView.java:98)
at org.nutz.plugins.view.freemarker.FreemarkerView.render(FreemarkerView.java:56)
at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:66)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
报错代码为:
private String getPath(String path) {
StringBuffer sb = new StringBuffer();
// 空路径,采用默认规则
if (Strings.isBlank(path)) {
sb.append(Mvcs.getServletContext().getRealPath(freeMarkerConfigurer.getPrefix()));
sb.append((path.startsWith("/") ? "" : "/")); //这里抛出空指针
sb.append(Files.renameSuffix(path, getExt()));
}
// 绝对路径 : 以 '/' 开头的路径不增加 '/WEB-INF'
else if (path.charAt(0) == '/') {
String ext = getExt();
sb.append(path);
if (!path.toLowerCase().endsWith(ext))
sb.append(ext);
}
// 包名形式的路径
else {
sb.append(path.replace('.', '/'));
sb.append(getExt());
}
return sb.toString();
}