zoukankan      html  css  js  c++  java
  • 编写一个JSP页面,实现根据一个人 18 位身份证显示生日的功能,要求把表达式,小脚本全部用到,

     编写思路:

    1. 身份证信息需要集合来存储,可用Set或者List, 将身份证号加入到集合中去,
    2. 通过循环(Iterator for循环)来遍历身份证,取出每个身份号,
    3. 通过字符串的方法取得年月日:

    substring(int beginIndex, int endIndex) 
              返回一个新字符串,它是此字符串的一个子字符串。

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>身份证</title>
    </head>
    <body>
    <% String id[]={"320483199503046516","320483199503046517"}; %>
    <table border="1">
    <tr bgcolor="pink"><td>身份证</td><td>生日</td></tr>
    <% for(int i=0;i<id.length;i++){ %>
        <tr>
        <td><%=id[1] %></td>
        <td><%=id[i].substring(6,10) %>-<%=id[i].substring(10,12) %>-
        <%=id[i].substring(12,14) %></td>
        </tr>
        <%}
    %>
    </table>
    </body>
    </html>

     

  • 相关阅读:
    换个格式输出整数
    c++入门构造函数
    接口继承与实现
    spring mvc 之@requestmapping
    RabbitMQ
    Socket通信原理
    TCP三次握手与四次挥手
    WIN 10家庭版没有Hyper-V
    aop 切面demo
    JVM之旅------jvm内存模型
  • 原文地址:https://www.cnblogs.com/sunstudy/p/12313705.html
Copyright © 2011-2022 走看看