JSP页面打印输出,两种方法。out、《%=


使用out.println()输出:

<%@ page contentType="text/html;charset=UTF-8"%>  
<html>  
<head><title>乘法口诀</title></head>  
<body>  
    使用out.println()打印乘法口诀:<br/>  
    <%  
        int cols,rows;  //列、行  
        out.println("<table border='1'>");          
        for(cols=1;cols<10;cols++){  
            out.println("<tr>");  
            for(rows=1;rows<=cols;rows++){  
                out.println("<td>"+cols+"*"+rows+"="+cols*rows+"</td>");  
            }  
            out.println("</tr>");       
        }         

        out.println("</table>");  
    %>  
</body>  
</html>

使用<%= %>表达式输出:

<%@ page contentType="text/html;charset=UTF-8"%>  
<html>  
<head><title>乘法口诀</title></head>  
<body>  
    使用<%=%>表达式打印乘法口诀:<br/>  
    <table border='1'>  
    <%  
        int cols,rows;  //列、行  
        for(cols=1;cols<10;cols++){  
    %>  
        <tr>  
    <%  
            for(rows=1;rows<=cols;rows++){  
    %>  
                <td><%=cols%>*<%=rows%>=<%=cols*rows%></td>  
    <%  
            }  
    %>                 
        </tr>   
    <%  
        }         
    %>  
    </table>  
</body>  
</html> 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM