简体   繁体   English

无法在grails中从控制器重定向到gsp

[英]Not able to redirect from controller to gsp in grails

I am new to grails,I am trying to redirect to render a gsp after doing some processing with my model object in controller but every time i am getting following error: 我是grails的新手,在控制器中对我的模型对象进行一些处理后,我尝试重定向以呈现gsp,但是每次遇到以下错误时,我都会尝试:

Line | Method
->> 195 | doFilter in PageFragmentCachingFilter.java
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    63 | doFilter in AbstractFilter.java
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   662 | run . .  in java.lang.Thread

I am able to redirect to another gsp if i dont process my domain(setProperties method) ie if I remove the for loop. 如果我不处理我的域(setProperties方法),即删除了for循环,则能够重定向到另一个gsp。

Following is my controller code: 以下是我的控制器代码:

def receiveClient() {
        PartyClient partyClientInstance=PartyClient.get(params.client1Id)
        for (String key : params.keySet()) {
            if(key.endsWith("Checked")){
                setProperties(key,partyClientInstance)
            }
        }
        render (view: "receiveClient",model: [partyClientInstance: partyClientInstance])
    }

def setProperties(String key,PartyClient partyClient){
    int i =key.indexOf("Checked");
    String property=key.substring(0, i);

    if(property.equals("firstName")){
        partyClient.setFirstName(params[key])
    }else if(property.equals("lastName")){
        partyClient.setLastName(params[key])
    }else if(property.equals("middleName")){
        partyClient.setMiddleName(params[key])
    }else if(property.equals("title")){
        partyClient.setTitle(params[key])
    }
}

Thanks in advance. 提前致谢。

只是一个猜测:尝试将您的方法setProperties()重命名为其他名称。

Try using a command object to present the receiveClient view. 尝试使用命令对象来呈现receiveClient视图。

By the way the error message that you pasted may not contain all the relevant information, your stacktrace is rather small... 顺便说一句,您粘贴的错误消息可能不包含所有相关信息,因此您的stacktrace非常小...

  • Once you get your partyClientInstance , copy it inside a command matching the domain properties. 获得partyClientInstance后 ,将其复制到与域属性匹配的命令中。
  • If your view has a form to save the model, then in the relevant action, copy the command to the model and persist the data if needed. 如果您的视图具有保存模型的表单,则在相关操作中,将命令复制到模型并根据需要保留数据。

Hope it helps. 希望能帮助到你。

You can always try grails-debug run-app and use an IDE to add breakpoints. 您可以随时尝试grails-debug run-app并使用IDE添加断点。 I am little skeptical about the usage of PartyClient in setProperties() . 我对setProperties()PartyClient的用法持怀疑态度。 I hope debugging would help. 我希望调试会有所帮助。 Debug port by default is 5005 . 调试端口默认为5005

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM