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>");
%>jsp页面输出的三种方式
</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>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论