文件: forward.jsp<%@ page contentType="text/html; charset=GB2312" %>
<html>
<head>
<title>forward文件</title>
</head>
<body>
<%-- 注意这个字串: "< jsp:include/>" --%>
<jsp:forward page="forward1.jsp">
<jsp:param name="txt1" value="< jsp:include/>"/> 
<jsp:param name="txt2" value="JSP"/> 
</jsp:forward>
</body>
</html>文件: forward1.jsp<%@ page contentType="text/html; charset=GB2312" %>
<html>
<head>
<title>forward1</title>
</head>
<body>
<b><center><br><font color=red><%= request.getParameter("txt1")%></font><br>
<font color=red><%= request.getParameter("txt2")%></font> </body>
</html>在forward.jsp 文件里, 字符串 "< jsp:include/>" , 在字符 '< ' 和' j' 之间有个空格, 如果没有这个空格, forward1.jsp 就不能接收txt1的值, 如何去掉这个空格呢? 

解决方案 »

  1.   

    或者 forward1.jsp 想接收 " <jsp:include/> " 这样的字符串, 应该如何处理呢?
      

  2.   

    原代码去掉空格时,浏览器中查看源文件,源文件中包含:
    .....
    <font color=red><jsp:include/></font><br>
    .....
    不能显示<jsp:include/>是因为浏览认为该串是错误的html标记,这个串被忽略掉了。
    forward1.jsp已经接收到了正确的字符串!
    要想能在页面中输出<jsp:include/>,可以修改forward.jsp,
    将"< jsp:include/>" 替换为"&lt;jsp:include/>"