一、JSP常用小知识点

(一)我们通常可以用一个“隐藏域”,来到给后台或者JS传递值

//这是传递给JS的写法
<input id="basePath" type="hidden" value="给后台的值"/>
备注:
    JS可通过"id"取出对应节点的值
//这是传递给后台的写法
<input name="basePath" type="hidden" value="给后台的值"/>
备注:
    后台一般是通过“request.getParameterValues("id");”来获取form表单传递过来的值,但是它只识别“name”,不识别“id”

(二)使用“foreach”和“if”标签

1.引入标签库
<%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core” %>
2.使用标签

//使用<c:forEach></c:forEach>标签
<c:forEach items="${messages}" var="message" varStatus="status">

//使用<c:if></c:if>标签
<c:if test="status % 2 != 0">style="background-color:#ECF6EE;"</c:if>

(三)href=”#”详解

<a href="#">

这个“#”在html中有什么作用?跳转到本页面顶部,一般建议写成javascript:void(0);要好一点,点了一点反应都没有,写#点了会跳一下的。

猜你喜欢

转载自blog.csdn.net/panchang199266/article/details/80255295