• js,js中使用正则表达式


    var KnowName = $.trim($("#know_name").val());//$.trim()去空格
    //KnowName == null || KnowName.trim() == '' //ie8不支持trim()方法
    if(!KnowName){//档knowName为null,"",undefined返回false
    $("#tongyi").html("");
    return;
    }

    问题:

    在一个页面创建信息后,请求转发到另一个页面(避免重复请求)
    显示效果:创建后要求弹出创建是否成功

    <%
        String KBROBJ = request.getParameter("KBROBJ");
        if(KBROBJ != null){
            if(!"0".equals(KBROBJ)){
    %>
                out.println("<script>alert('知识创建成功!')</script>"); 
    <%
            }else{
    %>
                out.println("<script>alert('知识创建失败!')</script>"); 
    <%            
            }
        }
    %>
    <script>
         if(window.location.search != null && window.location.search != ""){//window.location.search设置或返回url路径后的参数
             window.location.search = "";
         }
    </script>

     在js中使用正则表达式

     var reg = /^[0-9]*[1-9][0-9]*$/;
             var groupId = jqNotForOnline.trim(jqNotForOnline('#group_id').val());
             if(!reg.test (groupId ))
               {
                 alert ("组ID只能为正整数!");
                 return;
               }

    var time = data[i].create_time.match("\d{4}-\d{2}-\d{2}") + " " + data[i].create_time.match("\d{2}:\d{2}:\d{2}");
    str +="<td><label >"+time+"</label></td></tr>";

    <c:if test="${fn:length(myquestionlist) != 0}">

    <c:forEach items="${myquestionlist }" var="mq">

    关键在于<c:forEach>的varStatus属性,具体代码如下:

    <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <th>序号</th>
        <th>姓名</th>
    </tr>
    <c:forEach var="student" items="${ students}" varStatus="status">
    <tr>
        <td>${ status.index + 1}</td>
        <td>${ student.name}</td>
    </tr>
    </c:forEach>
    </table>

    备注:status.index是从0开始的。

  • 相关阅读:
    C++结构体成员列表初始化
    hdu-3790-最短路径问题(Dijkstra)
    hdu--1878--欧拉回路(并查集判断连通,欧拉回路模板题)
    nyoj-1278-Prototypes analyze(二叉排序树模板)
    hdu-5183-Negative and Positive (NP)(hash模板)
    nyoj-130-相同的雪花(hash)
    详细介绍C++STL:unordered_map
    NYOJ-626-intersection set(二分查找)
    hdoj-2141-Can you find it?(二分查找)
    HDU-1232-畅通工程(并查集)
  • 原文地址:https://www.cnblogs.com/lh-V/p/3694256.html
Copyright © 2020-2023  润新知