Jsp網頁動態

但是效果確是這樣的,求解問題在哪?
<%@?page?language="java"?import="java.util.*"?contentType="text/html;?charset=utf-8"%>
<%@page?import="java.text.*"?%>
<%@page?import="java.lang.String"?%>
<%
String?path?=?request.getContextPath();
String?basePath?=?request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN">
<html>
??<head>
????<base?href="<%=basePath%>">
????
????<title>My?JSP?'index.jsp'?starting?page</title>
<meta?http-equiv="pragma"?content="no-cache">
<meta?http-equiv="cache-control"?content="no-cache">
<meta?http-equiv="expires"?content="0">????
<meta?http-equiv="keywords"?content="keyword1,keyword2,keyword3">
<meta?http-equiv="description"?content="This?is?my?page">
<!--
<link?rel="stylesheet"?type="text/css"?href="styles.css">
-->
??</head>
??
??<body>
??<!--?我是html注釋,可在客戶端看見?-->
??<%--我是JSp注釋,在客戶端不可見?--%>
??<%?/*我是腳步注釋*/
???%>
???<h1>九九乘法表</h1>
????<hr>
???<%!//定義自定義變量或方法
??? String?fangfa(){
??? String?s="";
??? for(int?i=1;i<=9;i++){
for(int?j=1;j<=i;j++){
int?c=i*j;
s=i+"*"+j+"="+c;
}
?????s=s+"<br>";
}
return?s;
}
????%>
???<%
???SimpleDateFormat?date=new?SimpleDateFormat("yyyy/MM/dd");
???String?d?=date.format(new?Date());
????%>
????今天是:<%=d?%>+"<br>"
???
????<%=fangfa()%>
??</body>
</html>
2016-11-08
改成s+=i+"*"+j+"="+c;? 試試
2016-11-07
?????????for(int?i=1;i<=9;i++){ ????????????for(int?j=1;j<=i;j++){ ????????????????int?c=i*j; ????????????????s=i+"*"+j+"="+c; ????????????????} ?????????????????s=s+"<br>"; ????????????} ????????????return?s; ????????????}s=i+"*"+j+"="+c ?return的s在這里被覆蓋了