【疑难解答】JSP中使用include标签

本文探讨了在JSP中遇到的动态包含问题,主要聚焦于<jsp:include page="" />标签的使用。详细解析了`Stream closed`和`IllegalStateException`异常,提供了相应的解决方案。
<span style="font-family: arial, 'courier new', courier, 宋体, monospace; white-space: pre-wrap;">Servlet.service() for servlet [action] in context with path [/s] threw exception [java.lang.IllegalStateException: Exception occurred when flushing data] with root cause</span>
java.io.IOException: Stream closed
当出现这种错误时,
1:首先检查
	页面跳转后有没有加入return;
2:被包含的页面不要有多余的标签
	去掉被包含页面<html>,<head>
	但是某些JSP标签可以留下
	例如
	
<%@page import="com.utils.RefererUtils"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%  
		if(RefererUtils.isReferer(request, response)){
			response.sendRedirect(request.getContextPath()+"/index.jsp");
			return;
		}
	%>

3.检查inclde标签是否用错
		

1.<jsp:include page="" /> 这是动态包含

2.<%@include file="" %> 这是静态包含
如果你使用其中的一个标签出错的话,不妨换一个标签试试
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值