在grails中,我们在layouts\main.gsp中使用类似如下的代码来判断当前用户处于登录状态时显示相关的登录信息:

 <g:if test="${session.users}">

 ...

 </g:if>

 <g:else>

 ...

 </g:else>

但在运行时,发生了如下的异常:

Caused by GroovyPagesException: Error processing GroovyPageView: Cannot create a session after the response has been committed

->> 2886 | runWorker in \grails-app\views\layouts\main.gsp

要解决这个异常,可以使用如下方式来解决:

 <g:if test="${request.getSession(false)?.users}">

 ...

 </g:if>

 <g:else>

 ...

 </g:else>

也就是通过request对象来获取session时,不使用自动创建session的模式。

grails中报Cannot create a session after the response has been committed异常的解决办法的更多相关文章

  1. idea调试SpringMvc, 出现:”javax.servlet.ServletException: java.lang.IllegalStateException: Cannot create a session after the response has been committed"错误的解决方法

    调试拦截器出现以下错误: HTTP Status 500 - javax.servlet.ServletException: java.lang.IllegalStateException: Cann ...

  2. Cannot create a session after the response has been committed

    有时候在操作Session时,系统会抛出如下异常 java.lang.IllegalStateException: Cannot create a session after the response ...

  3. [Exceptions Spring 2] - Cannot create a session after the response has been committed

    2016-02-23 14:06:27,416 [http-bio-8080-exec-1] DEBUG [org.springframework.beans.factory.support.Defa ...

  4. CAS-ERR Cannot create a session after the response has been committed

    现象: 当cas 登录人数较少时候没有错误,但是用户过多时候出现下列err May-2016 18:09:11.932 SEVERE [http-nio-8080-exec-52] org.apach ...

  5. 关于springmvc重定向后Cannot create a session after the response has been committed问题

    首先先上代码吧,我在用springmvc进行response.sendRedirect(url);操作后报了Cannot create a session after the response has ...

  6. C#做音乐播放器时在自动下一曲中报异常的解决办法

    ---------------------- ASP.Net+Unity开发..Net培训.期待与您交流! ---------------------- 在利用Media Player做音乐播放器的时 ...

  7. 关于子线程使用Toast报错Can't create handler inside thread that has not called Looper.prepare()的解决办法

    形同如下代码,在Thread中调用Toast显示错误信息: new Thread(new Runnable(){ @Override public void run() { try{ weatherD ...

  8. OkHttp下载文件中途断网报Can't create handler inside thread that has not called Looper.prepare()异常的解决办法

    最近做项目时出现个问题. 在一个基类中,创建一个Handler对象用于主线程向子线程发送数据,代码如下: this.mThirdHandler = new Handler(){ @Override p ...

  9. windows系统下的maven项目放到linux系统中运行时报org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnection这种异常的解决办法

    这个错误的解决办法其实很简单你把连接mysql数据库的那个jar包换成linux版本的就行了: linux版本的连接mysql数据库的jar包链接:http://files.cnblogs.com/f ...

随机推荐

  1. TOMCAT服务器不写端口号、不写项目名访问项目、虚拟目录配置

    一.不写端口. 这个问题都被问烂了,因为TOMCAT默认的访问端口为8080,而TCP/IP协议默认80端口访问,大家之所以看到别的网站都不写端口号是因为人家用的的80端口访问的,而80端口因为的TC ...

  2. android-HttpClient上传信息(包括图片)到服务端

    需要下载apache公司下的HttpComponents项目下的HTTPCLIENT ----------地址为http://hc.apache.org/downloads.cgi 主要是用到了htt ...

  3. AOJ 2170 Marked Ancestor (基础并查集)

    http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=45522 给定一棵树的n个节点,每个节点标号在1到n之间,1是树的根节点,有如 ...

  4. 51nod 1050 循环数组最大子段和 (dp)

    http://www.51nod.com/onlineJudge/questionCode.html#problemId=1050&noticeId=13385 参考:http://blog. ...

  5. asp数据链接

    asp页面的中的数据库连接要进行唯一名称处理,不然页面中多个连接使用时,会出现连接莫名关闭.数据不能写入,但是页面也没报错.asp可以将有数据库连接的地方,提取成单独的函数.在每个方法单独命名数据库连 ...

  6. 头文件中的#ifndef/#define/#endif 的作用

    在一个大的软件工程里面,可能会有多个文件同时包含一个头文件,当这些文件编译链接成一个可执行文件时,就会出现大量重定义的错误.在头文件中实用#ifndef #define #endif能避免头文件的重定 ...

  7. 使用jQuery插件PrintArea进行html页面打印

    在开发系统时,我们一般会有统计分析的功能需求,而现在大多数系统都是使用B/S的形式开发. 所以,html报表打印,并且打印指定内容,成了必要的功能. 开源地址:https://github.com/R ...

  8. java.io.EOFException java.io.ObjectInputStream$PeekInputStream.readFully 错误

    Tomcat 启动时 java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully 错误 这 个错误 碰到好几 ...

  9. IBatis.Net 批量插入数据

    利用了iterate标签来做的: 先看iterate标签几个属性的: prepend-加在open指定的符号之前的符号,添加在语句的前面(可选) property-类型为ArrayList的用于遍历的 ...

  10. 读写INI辅助类

    using System.Text; using System.Runtime.InteropServices; using System; namespace Benson.INI读写 { #reg ...