交给JSP或者SERVLET来做吧,在BEAN里面不行

解决方案 »

  1.   

    sendRedirect只能在servlet容器中才能执行,详见API:----------------------------------------------------------------sendRedirect
    public void sendRedirect(java.lang.String location)
                      throws java.io.IOExceptionSends 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
    IllegalStateException - If the response was committed
      

  2.   

    我已经在bean中执行response.sendRedirect了,如果bean所在的jsp页面中没有response.sendRedirect,一些正常。
      

  3.   

    再bean里不好,如果倒入javax.servlet.http.*;等 不过如果jsp中也有的话,就会出现什么流已经写啦?感觉还是servlet中转 ,在jsp.javabean转不觉得太混乱吗?
      

  4.   

    这个方法只能用一次,
    sendRedirect以后,控制权就转移到下一个页面上了,此页面的response就已经失效了----------------------
    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.
      

  5.   

    jsp里执行到response.sendRedirect后return.
      

  6.   

    现在的问题是就算是我在jsp中实现权限检查,如果一个jsp页面中有两个response.sendRedirect也会出错。
      

  7.   

    sendRedirect的动作由servlet才能执行!