首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JSP 如何避免这个标记呢 " < "

2012-03-06 
JSP 如何处理这个标记呢 ?文件:forward.jsp%@pagecontentType text/htmlcharsetGB2312 %htm

JSP 如何处理这个标记呢 " < " ?
文件:   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的值,   如何去掉这个空格呢?  



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

热点排行
Bad Request.