<c:if test="${fn:contains(name, searchString)}">

来源:互联网 发布:欧文季后赛数据 编辑:程序博客网 时间:2024/06/06 02:26

关于<c:if test="${fn:contains(name, searchString)}">

网上举的例子不是很好,我试了好久才成功。

还是我来举个例子吧。

-------------------------------------------------------------------------------------

JSP表单提交页面主要代码:

<form method="post" action="result.jsp">
    <input type="text" name="interest" value="">
    <input type="submit" value="submit">

 </form>

---------------------------------------------------------------------------------------------------

JSP表单接收页面result.jsp主要代码:

<form method="post" action="">
    <input type="checkbox" name="interest" value="音乐" 
    <c:if test="${fn:contains(param.interest,'音乐')}">
    checked="checked"
    </c:if>
    >音乐
    </form>

注:以上代码实现的功能就是,如果接收到的param.interest包含【音乐】

二字,则复选框音乐就会被选中。


-----------------------------------------------------------------------------------------------------

效果截图:

//提交页面



//接收页面

0 0
原创粉丝点击