java - getOutputStream() has already been called ,but i just use getOutputStream one time in my SpringMVC code -
the process controller(jump) -> jsp(grid) ->controller(verification code) code
 controller(jump):
/**  * jump login in jsp  * @return  */ @requestmapping("/tologin") public string tologin( ) {     log.debug("to sign in!---------------------------------------<userinfocontroller>");     return "sign-in"; }   jsp(there no tag "<% ... %>"):
                    <div class="form-group">                         <label for="code">验证码</label>                         <input id="code" type="text" name="code" class="span3 form-control ">                         <a>                             <img alt="刷新验证码" src="${pagecontext.request.contextpath }/code">                         </a>                     </div>   controller(verification code):
    outputstream os = resp.getoutputstream();       imageio.write(buffimg, "jpeg", os);     os.close();   error :
java.lang.illegalstateexception: getwriter() has been called response @ org.apache.catalina.connector.response.getoutputstream(response.java:644) @ org.apache.catalina.connector.responsefacade.getoutputstream(responsefacade.java:196) @ com.wyk.pmsys.controller.codecontroller.getcode(codecontroller.java:107) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)
in servlet jsp convert java used "out.write()",is confilct code "resp.getoutputstream()"? that's ,how solve it; if else,what's ? , how solve it?
all need annotation responsebody method:
@requestmapping("/code") @responsebody //<---- here public void getcode(httpservletrequest req, httpservletresponse resp)           throws ioexception {      
Comments
Post a Comment