Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
condition <c:when test=""> within jstl <c:forEach>

beforehand I have model.addattribute(list, 'list') in which list is a list of VOs Within each VO I have choices=[val1,val2,val3...] and in some VOs I have choices=[]

I want to make a code in which:

  1. if choice doesn't have values: text type input appears
  2. and when it has values: radio type input appears

no 2. works fine, but I'm having trouble with the condition within my when statement.

<c:when test="${empty ${one.survey_choices}}">

I have also tried

<c:when test="${empty one.survey_choices}">

but both don't work.

Here's my code:

<c:forEach items="${surveyList}" var="one">
  <tr>
    <td style="text-align: left">
      <h4 class="fw-bold text-center mt-3"></h4>
      <p class="fw-bold">${one.survey_idx}.${one.survey_question}</p>
      <div class="form-check mb-2">
        <c:choose>
          <c:when test="${empty ${one.survey_choices}}"> <!-- ERROR!!! -->
            <p>success!!!</p>
            <div class="input-group mb-3">
              <div class="input-group-prepend">
                <span class="input-group-text" id="basic-addon1">${one.survey_idx}.${one.survey_question}</span>
              </div>
              <input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
            </div>
          </c:when>
          <c:otherwise>
            <c:forTokens items="${one.survey_choices}" var="choice" delims=",">
              <input class="form-check-input" type="radio" name="exampleForm" id="radioExample1" />
              <label class="form-check-label" for="radioExample1">
                <c:out value="${choice}" />
              </label>
            </c:forTokens>
          </c:otherwise>
        </c:choose>
      </div>
    </td>
  </tr>
</c:forEach>

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda