Engine.use().getTemplate(fileName)找不到文件

	String init(final HttpServletRequest request, final SqlSession sqlSession) {
		Map<String, Object> processData = this.processData(request, sqlSession);
		if (processData != null) {
			Set<Entry<String, Object>> entrySet = processData.entrySet();
			for (Entry<String, Object> entry : entrySet) {
				this.springData.put(entry.getKey(), entry.getValue());
			}
		}
		Engine use = Engine.use();
		String path = VIE_WBASE_PATH.concat(this.viewTemplate);
		/**
		 * 打印出来的地址是:
		 * /E:/islj/project/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/MangerSystem/WEB-INF/classes/core/view/test.html
		 */
		System.out.println(path);
		return use.getTemplate(path).renderToString(springData);
	}


抛出的异常:

com.jfinal.render.RenderException: java.lang.RuntimeException: File not found : null/E:/islj/project/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/MangerSystem/WEB-INF/classes/core/view/test.html
	at com.jfinal.render.TemplateRender.render(TemplateRender.java:62)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:108)
	at cn.gov.xsbn.core.ArrowUrlHandler.handle(ArrowUrlHandler.java:40)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: File not found : null/E:/islj/project/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/MangerSystem/WEB-INF/classes/core/view/test.html
	at com.jfinal.template.source.FileSource.getContent(FileSource.java:70)
	at com.jfinal.template.Engine.buildTemplateBySourceFactory(Engine.java:153)
	at com.jfinal.template.Engine.getTemplate(Engine.java:138)
	at cn.gov.xsbn.core.AbstractView.init(AbstractView.java:74)
	at cn.gov.xsbn.core.ViewDirective.exec(ViewDirective.java:67)
	at com.jfinal.template.stat.ast.StatList.exec(StatList.java:68)
	at com.jfinal.template.Template.render(Template.java:55)
	at com.jfinal.render.TemplateRender.render(TemplateRender.java:60)
	... 22 more

这是什么情况啊?

评论区

JFinal

2018-01-05 11:29

如果你的模板在 class path 或者jar 包之中,配置一下:
Engine.use().setSourceFactory(new ClassPathSourceFactory());

如果不是的话,配置一下这个:
Engine.use().setBaseTemplatePath(....);

热门反馈

扫码入社