Jfinal + Jetty http://localhost/test/post 能返回post这个action下的renderText(),但不能返回render("test.html")并且出现500错误

chris_hellowoo 发布于 2015/01/19 09:23
阅读 2K+
收藏 0

如题,

配置路由:

public void configRoute(Routes me) {
me.add("/test",HelloController.class);
}

文件目录结构:

错误类型:

2015-1-19 9:11:08 com.jfinal.core.ActionHandler error
严重: /test/post
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:61)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:73)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55)
... 25 more
Caused by: java.lang.NoClassDefFoundError: freemarker/template/TemplateException
at com.jfinal.render.RenderFactory$FreeMarkerRenderFactory.getRender(RenderFactory.java:256)
at com.jfinal.render.RenderFactory.getRender(RenderFactory.java:142)
at com.jfinal.core.Controller.render(Controller.java:893)
at Demo.HelloController.post(HelloController.java:16)
... 30 more
Caused by: java.lang.ClassNotFoundException: freemarker.template.TemplateException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:430)
at com.jfinal.server.JFinalClassLoader.loadClass(JFinalClassLoader.java:53)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 34 more


加载中
0
l
leiloky


demoConfig里需要更改视图模式为jsp

public void configConstant(Constants me) {

    me.setDevMode(true);
    me.setViewType(ViewType.JSP);
}
javaer
javaer
回复 @chris_hellowoo : 你导入freemark.jar包了??
chris_hellowoo
chris_hellowoo
刚实验了,成功了,先谢谢你了。但是我不懂的是,为什么用默认的freemarker视图就不可以,一定要设置成为jsp渲染视图呢?
0
chris_hellowoo
chris_hellowoo
我知道了,要用Freemarker,必须添加jar包
返回顶部
顶部