远程功能不起作用

时间:2014-07-04 10:59:39

标签: grails groovy hql gorm

以下是我的Pgtyp.groovy(域类):

package marchmock2

class Pgtyp {
   Date date_hour
   String mv
   String pagetype
   Integer visits
   Integer visits_ly
   Integer visits_lw
   String time_period
   String platform
   String device
   String browser

   static mapping = {
      table "pgtyp"
      version false 
      date_hour column: "date_hour"
      mv column: "mv"
      pagetype column: "pagetype"
      visits column: "visits"
      visits_ly column:"visits_ly"
      visits_lw column:"visits_lw"
      time_period column:"time_period"
      platform column:"platform"
      device column:"device"
      browser column:"browser"
   }       

   static constraints = {
   }
}

这就是我的控制器的样子:

package marchmock2
import grails.converters.*
import groovy.sql.Sql 

class PgtypController {

   def ajaxGetMv = {
      def pgtyp = Pgtyp.get(params.id)
      render pgtyp as JSON
   }

   def index() { 
   }
}

最后,这是我的index.gsp:

<html>
   <head>
      <g:javascript src="jquery-1.10.2.min.js"/>
      <g:javascript src="prototype.js"/>
   </head>
   <body>
      <form>
         <g:select from="['AFFILIATES', 'SEO', 'SEM','DISPLAYADS']" name="mv" onchange="${remoteFunction(
        controller:'Pgtyp', 
        action:'ajaxGetMv', 
        params:'\'id=\' + escape(this.value)',
        onSuccess: 'printpgtyp(data)')}"></g:select>
      </form>
      <g:javascript>
         function printpgtyp(data) {
            console.log(data)
         }
      </g:javascript>
   </body>
</html>

当我运行我的应用程序时,我得到一个下拉列表并从中选择任何选项我收到错误说:

POST http://localhost:8080/marchmock2/pgtyp/ajaxGetMv 500 (Internal Server Error) 

我该怎么办?我写作的方式有什么错误,或者我误解了什么?任何帮助,将不胜感激。

更新

|
2014-07-04 16:37:23,149 [http-bio-8080-exec-10] ERROR [/marchmock2].[gsp]  - Servlet.service() for servlet   [gsp] in context with path [/marchmock2] threw exception
Message: It looks like you are missing some calls to the r:layoutResources tag. After rendering your page the       following have not been rendered: [defer]
Line | Method
->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run . . . in java.lang.Thread

UPDATE2

在stackoverflow上回答后,我改为并且第一次 UPDATE 中提到的错误消失了。但是,当我选择SEO#39;从下拉列表中,我收到以下错误

TypeMismatchException occurred when processing request: [POST] /marchmock2/pgtyp/ajaxGetMv - parameters:
id: SEO
Provided id of the wrong type for class marchmock2.Pgtyp. Expected: class java.lang.Long, got class     java.lang.String. Stacktrace follows:
Message: Provided id of the wrong type for class marchmock2.Pgtyp. Expected: class java.lang.Long, got class      java.lang.String 

0 个答案:

没有答案