jsp的一些标签库

核心标签库

引用:<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:if>,<c:forEach>,等等

举例:

        <input type="radio" name="gender" value="男"<c:if test="${stu.gender}=='男' ">checked</c:if>>男
        <input type="radio" name="gender" value="女"<c:if test="${stu.gender=='女'} ">checked</c:if>>女

方法标签库

引用:  <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

举例:

        <input type="checkbox" name="hobby" value="游泳" <c:if test="${fn:contains(stu.hobby,'游泳') }">checked</c:if>>游泳
        <input type="checkbox" name="hobby" value="篮球"<c:if test="${fn:contains(stu.hobby,'篮球') }">checked</c:if>>篮球
        <input type="checkbox" name="hobby" value="足球"<c:if test="${fn:contains(stu.hobby,'足球') }">checked</c:if>>足球
        <input type="checkbox" name="hobby" value="看书"<c:if test="${fn:contains(stu.hobby,'看书') }">checked</c:if>>看书
        <input type="checkbox" name="hobby" value="写字"<c:if test="${fn:contains(stu.hobby,'写字') }">checked</c:if>>写字
    其中fn.contains(" 源字符串","子字符串 ")第一个参数是源字符串,第二个参数是子字符串

猜你喜欢

转载自blog.csdn.net/qq_37706228/article/details/81236699