从数据库中检索时如何更新多个复选框值

时间:2014-07-12 15:07:40

标签: jsp taglib

使用此标签lib

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

但是收到错误

当未指定默认命名空间时,函数contains必须与前缀一起使用

我正在使用这种方法。在从数据库中提取时检查多个复选框

   <c:set var="medium" value="<%=rs.getString("medium")%>" />

       English
    <input type="checkbox" name="C1" <c:if test="${fn:medium.contains('English')}">checked</c:if>>
    Kannada
    <input type="checkbox" name="C1"
           <c:if test="${medium.contains('Kannada')}">checked</c:if>>
    Hindi
    <input type="checkbox" name="C1"
           <c:if test="${medium.contains('Hindi')}">checked</c:if>>

2 个答案:

答案 0 :(得分:1)

确保taglib支持fm

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

并尝试更改

<c:if test="${fn:medium.contains('English')}">checked</c:if>

<c:if test="${fn:contains(medium, 'English')}">checked</c:if>

答案 1 :(得分:1)

将您的代码更改为:

    English
    <input type="checkbox" name="C1" 
           <c:if test="${fn:contains(medium,'English')}">checked</c:if>>
    Kannada
    <input type="checkbox" name="C1"
           <c:if test="${fn:contains(medium,'Kannada')}">checked</c:if>>
    Hindi
    <input type="checkbox" name="C1"
           <c:if test="${fn:contains(medium,'Hindi')}">checked</c:if>>

并包含taglibs

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

http://www.tutorialspoint.com/jsp/jstl_function_contains.htm

相关问题