private Object file = null;
private OutputStream out = null; @SuppressWarnings("static-access")
public int doStartTag() throws JspTagException {
return super.SKIP_BODY;
} @SuppressWarnings("static-access")
public int doEndTag() throws JspTagException {
HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
try {
out = response.getOutputStream();
out.flush();
byte[] fileByte = (byte[]) file;
out.write(fileByte);
out.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null)
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
} } return super.SKIP_BODY;
}运行时报错:getWrite()已经被call!!??
网上都说getOutPutStream()和getWrite()只能调用一个
我这里只调用getOutPutStream,为什么还报错
?????
private OutputStream out = null; @SuppressWarnings("static-access")
public int doStartTag() throws JspTagException {
return super.SKIP_BODY;
} @SuppressWarnings("static-access")
public int doEndTag() throws JspTagException {
HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
try {
out = response.getOutputStream();
out.flush();
byte[] fileByte = (byte[]) file;
out.write(fileByte);
out.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null)
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
} } return super.SKIP_BODY;
}运行时报错:getWrite()已经被call!!??
网上都说getOutPutStream()和getWrite()只能调用一个
我这里只调用getOutPutStream,为什么还报错
?????
是不是在任务管理器里有二个javaw?
return null;
java.lang.IllegalStateException: getWriter() has already been called for this response
at org.apache.catalina.connector.Response.getOutputStream(Response.java:573)
at org.apache.catalina.connector.ResponseFacade.getOutputStream(ResponseFacade.java:183)
at struts.ImageTag.doEndTag(ImageTag.java:36)
at org.apache.jsp.inde0x_jsp._jspx_meth_mytag_005fhello_005f0(inde0x_jsp.java:244)
at org.apache.jsp.inde0x_jsp._jspService(inde0x_jsp.java:91)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:139)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)找了很久,还是没有解决!!郁闷!!
Struts2.0图片显示问题
中继续关注:感想各位的讨论!!