JSTL导入标记抛出带有相对URL的Java.lang.IllegalStateException

|| 在Java Web应用程序中,我在Jboss 4.2.3上使用Stripes框架。在我使用JSP时
<c:import url=\"http://localhost:8080/contextPath/txts/someID\" charEncoding=\"UTF-8\"/>
效果很好,其内容包含在输出HTML中。但是,这不起作用
<c:import url=\"/txts/someID\" charEncoding=\"UTF-8\"/>
并引发此错误(整个堆栈太大,无法在此处粘贴,因此我包括了前几行):
java.lang.IllegalStateException: Unexpected internal error during &lt;import&gt: Target servlet called getOutputStream(), then getWriter()
at org.apache.taglibs.standard.tag.common.core.ImportSupport$ImportResponseWrapper.getOutputStream(ImportSupport.java:492)
at net.sourceforge.stripes.action.StreamingResolution.stream(StreamingResolution.java:443)
at net.sourceforge.stripes.action.StreamingResolution.execute(StreamingResolution.java:240)
at net.sourceforge.stripes.controller.DispatcherHelper$7.intercept(DispatcherHelper.java:508)
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
at org.stripesstuff.plugin.security.SecurityInterceptor.interceptResolutionExecution(SecurityInterceptor.java:225)
at org.stripesstuff.plugin.security.SecurityInterceptor.intercept(SecurityInterceptor.java:129)
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at net.sourceforge.stripes.controller.HttpCacheInterceptor.intercept(HttpCacheInterceptor.java:99)
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
at net.sourceforge.stripes.controller.DispatcherHelper.executeResolution(DispatcherHelper.java:502)
at net.sourceforge.stripes.controller.DispatcherServlet.executeResolution(DispatcherServlet.java:286)
at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:170)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
任何意见,将不胜感激。 问候     
已邀请:
问题在于,如果使用阅读器打开了StreamingResolution,那么它(自然地)会打开一个Writer以将输出流式输出。 c:import标记无关紧要,仅在响应上调用getOutputStream。 因此,为减轻这种情况,您不应将Reader用作StreamingResolution,而需要使用InputStream创建StreamingResolution。 另一个选项是重写StreamingResolution.stream()方法。 条纹基本上是为您“做正确的事”,但是c:import正在您的游行中如雨后春笋般冒出来。 幸运的是,您可以控制Stripes动作。与c:import操作无关。     
问题不在JSTL中,而在目标servlet中。异常消息很清楚-您不应为相同的响应呼叫
getOutputStream()
getWriter()
。     

要回复问题请先登录注册