关于rythm使用问题。

发布于 2021-11-24 05:57:15 字数 6204 浏览 722 评论 2


最近使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如此安好 2021-11-29 01:09:33

这个问题很奇怪,不过可以自己解决。解决方式为:当你程序处于启动状态时,你随便在java代码中输个空格,然后保存,此时jfinal会重新reload.当出现Loading changes ...... Loading complete.后,你再去访问页面,发现可以了。

泛泛之交 2021-11-24 20:17:24

代码大致如下:

 

@import com.jfinal.plugin.activerecord.*
@import org.codedream.spider.model.tasktable

@import org.codedream.spider.SpiderThreads
 @extends(shared._layout,title:"任务列表")
 @args Page tasklist
 @args List<tasktable> task11

 
<table class="table table-striped">
   
    <tr>
     <th >id</th>
     <th >任务名称</th>
     <th >操作</th>
    </tr>
    
      @for(tasktable x:task11) {
         
    <tr>
     <td style="text-align:left;">@x.id@</td>
     <td style="text-align:left;">@x.taskname@</td>
     <td style="text-align:left;">
       <div class="btn-group" role="group">
。。。

  }

 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文