java.lang.IllegalStateException异常解决办法

最近在使用response.sendRedirect()时出现如下错误:
java.lang.IllegalStateException
            org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:423)

经过分析、查看jdk文档终于找到解决的办法,在response.sendRedirect()方法后加return语句即可,如下:
response.sendRedirect("login.jsp");
            return;

原因是:在程序中两次调用了response.sendRedirect()方法。

jdk5.0文档中很清楚地介绍了出现IllegalStateException异常的可能情况:

1)同一个页面中再次调用response.sendRedirect()方法。
2)提交的URL错误,即不是个有效的URL。

sendRedirect
            void sendRedirect(java.lang.String location)
            throws java.io.IOException
            Sends a temporary redirect response to the client using the  specified redirect location URL. This method can accept relative URLs;  the servlet container must convert the relative URL to an absolute URL  before sending the response to the client. If the location is relative  without a leading '/' the container interprets it as  relative to the current request URI. If the location is relative with a  leading '/' the container interprets it as relative to the servlet container root. 
            If the response has already been committed, this method  throws an IllegalStateException. After using this method, the response  should be considered to be committed and should not be written to.

Parameters: 
            location - the redirect location URL 
            Throws: 
            java.io.IOException - If an input or output exception occurs 
            java.lang.IllegalStateException - If the response was  committed or if a partial URL is given and cannot be converted into a  valid URL

转载于:https://www.cnblogs.com/Eric-5279/p/4729099.html

关于 java 上传,下载和导入报java.lang.IllegalStateException异常解决办法相关推荐

  1. java微信上传本地视频教程_java微信开发之上传下载多媒体文件,java上传下载_PHP教程...

    java微信开发之上传下载多媒体文件,java上传下载 回复图片.音频.视频消息都是需要media_id的,这个是需要将多媒体文件上传到微信服务器才有的. 将多媒体文件上传到微信服务器,以及从微信服务 ...

  2. [前台]---js重复上传一张图片两次,第二次失败的解决办法和思路

    js重复上传一张图片两次,第二次会失败,解决办法就是修改input的value值. 先上代码: <input style="display:none" type=" ...

  3. 软件测试,对于文件的上传下载,导入导出的操作的测试点

    上传下载 1.文件类型 1 .各种常见的文件类型,包括bat, xls, xlsx, doc, exe, jsp, rar, zip, iso等,以及各种视频.音频和图片等. 2.改文件名后缀,例如把 ...

  4. 使用阿里EasyExcel实现上传下载、导入导出Excel

    首先引入pom依赖: <dependency><groupId>com.alibaba</groupId><artifactId>easyexcel&l ...

  5. java上传文件到Oracle_用java实现ORACLE数据库的文件上传、下载

    文件上传使用: 的 UploadBean JAVA包,他的文件上传做的还不错,可进行目录或数据库的文件上传,默认使用的是ORACLE 的LONGRAW子段类型,可使用BLOB类型,但需要使用扩展JAV ...

  6. java歌曲上传下载功能实现,Java上传下载功能的实现详解

    上传下载是很简单的功能,但是每次用的时候还是要查,这里整理一下 前台: 提交 主要注意: enctype="multipart/form-data" method="po ...

  7. MinIO安装及使用教程(windows) 及java 上传 下载 windows minio 修改密码修改 MINIO_ACCESS_KEY minio开机启动

    1.下载安装地址(我下的是windows版本):https://min.io/download#/windows 2.新建一个目录存放minio文件,我建的文件名叫 D:\minioData,CMD进 ...

  8. minio 文件预览_MinIO安装及使用教程(windows) 及java 上传 下载

    2.新建一个目录存放minio文件,我建的文件名叫 D:\minioData,CMD进入刚刚下载的minio.exe所在目录, 直接在cmd下运行:minio.exe server D:\minioD ...

  9. aws s3 獲取所有文件_通过Java上传下载AWS S3文件,并解决文件数量超过1000的问题...

    1 前言 Amazon S3 (Simple Storage Service)是很常用的文件存储服务,我们的场景是上游把流水文件放到S3,我们再从S3读取并对账. 2 初始化S3 首先要获取相关的账号 ...

  10. flex java 上传下载_完整的Flex多文件上传实例

    客户端代码:fileUpload.xml-------------------------------------------------------------------------------- ...

最新文章

  1. MPB:南农金巍等-​​​瘤胃甲烷菌的分离培养与保存
  2. 通过界面生成时不存在的数据刷新界面引起的卡顿问题
  3. 在Microsoft VS.net 2005下开发Linux环境的网站应用
  4. php爬虫框架选用什么
  5. 饿了么,美团外卖红包小程序欢迎了解一下(0基础搭建自己的外卖分销cps小程序)
  6. 5试点城市BIM/CIM平台情况盘点
  7. 六、银行会计核算(全是重点)
  8. C语言time.h中srand(),rand()等等函数产生随机数的用法。
  9. Vim编辑器基本操作
  10. Photoshop文字之——制作写在宣纸上的水彩字特效
  11. 计算机二级和英语六级什么时候出成绩,英语四六级口语考试成绩确定标准是什么?成绩何时发布?...
  12. Python||报错:TypeError: can only join an iterable
  13. OpenCV VideoWriter报错: FFMPEG: tag ‘MP4V‘ is not supported with codec id 12 and format mp4解决方法
  14. 小米手机4c获取Root权限的流程
  15. 计算机画大熊猫教案,幼儿园大班《画熊猫》教案
  16. 程序猿媳妇儿注意事项
  17. MATLAB——观察吉布斯效应
  18. ros借助讯飞sdk实现问答机器人解决讯飞语音sdk11212erro
  19. Keil编译时报“extended constant initialiser used”警告
  20. 智能手机无线充台灯触摸芯片-DLT8T02S

热门文章

  1. 费波纳奇数c语言,费波纳切数列用C语言怎么编程
  2. PHP sql IN查询改成子查询
  3. html设置表格边框样式
  4. java实用技巧论坛_学习Java前要掌握6大技巧!
  5. java程序拦截dde漏洞问题_Office DDE漏洞学习笔记
  6. You need to use a Theme.AppCompat theme (or descendant) with this activity
  7. CSDN寄送的礼物,博客评选的阳光普照奖
  8. 别人回答工作中的问题,要自行判断是否正确
  9. 做软件,运气、天赋、智商、勤奋,你占了几样?
  10. debian samba出错:set_variable_helper(yes ): value is not boolean!