JSP拔萃

<jsp:setProperty name="foo" property="fruit" param="fruit" />
相当于调用foo.setFruit(request.getParameter("fruit"))
<jsp:setProperty name="foo" property="fruit" value="fruit" />

相当于调用foo.setFruit("fruit")

<jsp:setProperty name="foo" property="*" />

储存用户在Jsp输入的所有值,用于匹配Bean中的属性。在Bean中的属性的名字必须和request对象中的参数名一致.


<%@ include file="foo.jsp" %>

包含另外的jsp


<jsp:forward page="one.jsp"/>  跳转页面
getServletConfig().getServletContext().getRequestDispatcher(
                   "/jsp/jsptoserv/hello.jsp").forward(request, response);  ServerLet to Jsp

IF

<c:if test="${2>0}">
        <p>It's true that (2>0)! Working.</p>
    </c:if>

Foreach

<c:forEach var="item" begin="1" end="10">
        ${item}
    </c:forEach>

    <% Vector v = new Vector();
        v.add("One"); v.add("Two"); v.add("Three"); v.add("Four");

        pageContext.setAttribute("vector", v);
    %>

    <h3>Iterating over a Vector</h3>

    <c:forEach items="${vector}" var="item" >
        ${item}
    </c:forEach>

Switch Choose

 <c:choose>
        <c:when test="${index == 1}">
          One!<br/>
        </c:when>
        <c:when test="${index == 4}">
          Four!<br/>
        </c:when>
        <c:when test="${index == 3}">
          Three!<br/>
        </c:when>
        <c:otherwise>
          Huh?<br/>
        </c:otherwise>
      </c:choose>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值