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开始的。