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> 
原文地址:https://www.cnblogs.com/lx06/p/15686266.html