on
java(자바)에서 alert띄우기(java.lang.IllegalStateException: Cannot...
java(자바)에서 alert띄우기(java.lang.IllegalStateException: Cannot...
반응형
java(자바)에서 alert띄우기(java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed)
1.방법
if("NG"=="NG"){ response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); out.println("alert('엑셀파일을 확인해주세요.'); history.go(-1);"); out.flush(); response.flushBuffer(); out.close(); }
기존방법을 사용할때
-java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
-에러가 발생할수 있다.
2.방법
if(excelInsert=="NG"){ Writer out = response.getWriter(); String message = URLEncoder.encode("엑셀파일을 확인해주세요.","UTF-8"); response.setContentType("text/html; charset=UTF-8"); out.write("alert(decodeURIComponent('"+message+"'.replace(/\\+/g, '%20'))); location.href='/admin/main.do?mnu_url=/admin/civilOrganList.do&mnu_cd="+civilOrganVo.getMnu_cd()+"'"); out.flush(); response.flushBuffer(); out.close(); return null; }
반응형
from http://baytime0077.tistory.com/137 by ccl(A) rewrite - 2021-10-26 11:27:43