关于rythm使用问题。
最近使用jfinal + rythm时发现如下奇怪的问题:
2015-04-02 21:46:29 [ERROR]-[Thread: qtp1637097460-33]-[com.jfinal.core.ActionHandler.handle()]: / com.jfinal.render.RenderException: org.rythmengine.exception.RythmException: org.codedream.spider.model.tasktable cannot be cast to org.codedream.spider.model.tasktable Template: /Home/index.html Relevant template source lines: ------------------------------------------------- 29: <th >id</th> 30: <th >任务名称</th> 31: <th >操作</th> 32: </tr> 33: >> 34: @for(tasktable x:task11) { 35: 36: <tr> 37: <td style="text-align:left;">@x.id@</td> 38: <td style="text-align:left;">@x.taskname@</td> 39: <td style="text-align:left;"> 40: <div class="btn-group" role="group"> Relevant Java source lines: ------------------------------------------------- 125: { 126: __Itr<tasktable> __v0 = __Itr.valueOf(task11); //line: 34 127: int x_size = __v0.size(); //line: 34 128: if (x_size > 0) { //line: 34 129: int x_index = 0; //line: 34 >> 130: for(tasktable x : __v0) { //line: 34 131: x_index++; //line: 34 132: boolean x_isOdd = x_index % 2 == 1; //line: 34 133: java.lang.String x_parity = x_isOdd ? "odd" : "even"; //line: 34 134: boolean x_isFirst = x_index == 1; //line: 34 135: boolean x_isLast = x_index >= x_size; //line: 34 136: org.rythmengine.utils.RawData x_sep = new org.rythmengine.utils.RawData(x_isLast ? "" : ","); //line: 34 at com.jfinal.core.RythmPlugin.render(RythmPlugin.java:111) at org.rythmengine.jfinal.RythmRender.render(RythmRender.java:39) at com.jfinal.core.ActionHandler.handle(ActionHandler.java:92) 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(Unknown Source) Caused by: org.rythmengine.exception.RythmException: org.codedream.spider.model.tasktable cannot be cast to org.codedream.spider.model.tasktable Template: /Home/index.html Relevant template source lines: ------------------------------------------------- 29: <th >id</th> 30: <th >任务名称</th> 31: <th >操作</th> 32: </tr> 33: >> 34: @for(tasktable x:task11) { 35: 36: <tr> 37: <td style="text-align:left;">@x.id@</td> 38: <td style="text-align:left;">@x.taskname@</td> 39: <td style="text-align:left;"> 40: <div class="btn-group" role="group"> Relevant Java source lines: ------------------------------------------------- 125: { 126: __Itr<tasktable> __v0 = __Itr.valueOf(task11); //line: 34 127: int x_size = __v0.size(); //line: 34 128: if (x_size > 0) { //line: 34 129: int x_index = 0; //line: 34 >> 130: for(tasktable x : __v0) { //line: 34 131: x_index++; //line: 34 132: boolean x_isOdd = x_index % 2 == 1; //line: 34 133: java.lang.String x_parity = x_isOdd ? "odd" : "even"; //line: 34 134: boolean x_isFirst = x_index == 1; //line: 34 135: boolean x_isLast = x_index >= x_size; //line: 34 136: org.rythmengine.utils.RawData x_sep = new org.rythmengine.utils.RawData(x_isLast ? "" : ","); //line: 34 at Home_index_html__R_T_C__.(/Home/index.html:34) at Home_index_html__R_T_C__.build(Home_index_html__R_T_C__.java:130) at org.rythmengine.template.TemplateBase.__internalBuild(TemplateBase.java:664) at org.rythmengine.template.TemplateBase.__internalRender(TemplateBase.java:737) at org.rythmengine.template.TemplateBase.render(TemplateBase.java:571) at com.jfinal.core.RythmPlugin.render(RythmPlugin.java:109) ... 26 more Caused by: java.lang.ClassCastException: org.codedream.spider.model.tasktable cannot be cast to org.codedream.spider.model.tasktable ... 31 more
看日志应该是rythm抛出来的,classcast类型一模一样,结果还说cannot be cast to 。
而且我要把args 的变量改一下,然后在controller里setAttr时也改一下,重新启动,会好。但过一会又不行了,哪位遇到这种问题,求指教!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题很奇怪,不过可以自己解决。解决方式为:当你程序处于启动状态时,你随便在java代码中输个空格,然后保存,此时jfinal会重新reload.当出现Loading changes ...... Loading complete.后,你再去访问页面,发现可以了。
代码大致如下: