今天实战项目要求:编写一个JSP页面,实现根据一个人的18位身份证显示出生日的功能,要求把表达式声明和Scriptlet全部用到,并把结果显示在表格中,如下图所示
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<style >
#a{
border-style: solid;
border-width: 1px;
border-color: black;
border-collapse:collapse;
width:100%;
border-right: none;
border-left: none;
}
.b{
border-style: solid;
border-width: 1px;
border-color: black;
border-collapse:collapse;
border-right: none;
}
.c{
border-style: solid;
border-width: 1px;
border-color: black;
border-collapse:collapse;
border-right: none;
border-left: none;
}
.d{
background: darkgray;
}
</style>
</head>
<body>
<%!
String[] id={"010020199601026929","010020199711126928"};
public String getId(int idd){
String id1=id[idd].substring(6,10)+"-"+id[idd].substring(10,12)+"-"+id[idd].substring(12,14);
return id1;
}
%>
<table id='a'>
<tr class='d'>
<th class='c'>身份证</th>
<th class='b'>生日</th>
</tr>
<%for(int i=0;i<id.length;i++){%>
<tr>
<td class='c'><%=id[i]%></td>
<td class='b'><%=getId(i)%></td>
</tr>
<%}%>
</table>
</body>
</html>