HTML - THYMELEAF - pass parameter

Asked

Viewed 677 times

1

I created a parameter in Procedurecallerrepository and Procedurecallerrepositoryimpl So far everything ok my error is in html and I don’t know where I’m going wrong (I’m sorry if it’s something silly but I’m still learning)

but the part I need is this:

<form method="GET" th:action="@{/acompanhamentoprimeiropedido}">
    <label>Busca</label>
     <input class="input-sm form-control" type="text" name="parametroBuscaPrimeiroPedido" />

My parameter is the first request and the error that appears on the screen is : There was an Unexpected error (type=Bad Request, status=400). Required String Parameter 'parametroBuscaPrimarPedido' is not present

someone could give me a light on how to pass the parameter using Thymeleaf here in html?

follows my HTML code:

<!DOCTYPE html>

Follow-up First Request Date of Request: Up until Seeking

    <div class="col-xs-12 col-md-12">
        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
            <th:block th:each="diaPedido : ${listaDias}">
                <div class="panel panel-info">
                    <div class="panel-heading panel-heading-diaPedido" role="tab" th:id="'heading-' + ${diaPedido}">
                        <h4 class="panel-title text-left" role="button" data-toggle="collapse" data-parent="#accordion" th:href="'#collapse-' + ${diaPedido}" aria-expanded="false" aria-controls="collapseOne">
                            <a th:text="${#strings.substring(diaPedido,8,10)+'/'+#strings.substring(diaPedido,5,7)+'/'+#strings.substring(diaPedido,0,4)}"> </a> <i class="fas fa-caret-down pull-right"></i>
                        </h4>
                    </div>
                    <div th:id="'collapse-' + ${diaPedido}" class="panel-collapse collapse" role="tabpanel" th:attr="aria-labelledby='heading-' + ${diaPedido}">
                        <div class="list-group">
                            <div class="table-responsive display">
                                <table class="table table-bordered table-striped">
                                    <thead>
                                        <tr style="font-size: 12px">
                                            <th class="text-center col-md-2">Hora</th>
                                            <th class="text-center col-md-2">Master</th>
                                            <th class="text-center col-md-1 hidden-xs">Pedido</th>
                                            <th class="text-center col-md-4">Fantasia</th>
                                            <th class="text-center col-md-2">Contato</th>
                                            <th class="text-center col-md-1 hidden-xs">Telefone</th>
                                            <th class="text-center col-md-1 hidden-xs">Faturado</th>
                                            <th class="text-center col-md-1 hidden-xs">Embarcado</th>
                                            <th class="text-center col-md-1 hidden-xs">Previsão</th>
                                            <th class="text-center col-md-1">Entrega</th>
                                            <th class="text-center col-md-1"></th>
                                            <th class="text-center col-md-1"></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <th:block th:each="primeiroPedido : ${listaPrimeiroPedido}">
                                            <tr th:if="${#strings.replace(primeiroPedido[6],'-','') == #strings.replace(diaPedido,'-','')}">
                                                <td th:text="${#strings.isEmpty(primeiroPedido[6])  ? primeiroPedido[7] : primeiroPedido[7]}"></td>
                                                <td th:text="${primeiroPedido[0]}"></td>
                                                <td class="hidden-xs" th:text="${primeiroPedido[5]}"></td>
                                                <td th:text="${primeiroPedido[2]}"></td>
                                                <td th:text="${primeiroPedido[3]} "></td>
                                                <td class="hidden-xs" th:text="${#strings.replace(primeiroPedido[4],' ','')}"></td>
                                                <td class="hidden-xs" th:text="${#strings.isEmpty(primeiroPedido[8])  ? '' : #dates.format(primeiroPedido[8], 'dd/MM/yyyy')+' '+primeiroPedido[9]} "></td>
                                                <td class="hidden-xs" th:text="${#strings.isEmpty(primeiroPedido[10])  ? '' : #dates.format(primeiroPedido[10], 'dd/MM/yyyy')+' '+primeiroPedido[11]}"></td>
                                                <td class="hidden-xs" th:text="${#dates.format(primeiroPedido[12], 'dd/MM/yyyy')}"></td>
                                                <td th:text="${#strings.isEmpty(primeiroPedido[14])  ? '' : #dates.format(primeiroPedido[13], 'dd/MM')}"></td>
                                                <td class="text-center"><span class="label" th:classappend="${#strings.isEmpty(primeiroPedido[17])  ? 'label-danger' : 'label-success'}"> </span></td>
                                                <td class="text-center"><a class="btn btn-link btn-xs"> <span data-toggle="modal" data-target="#exampleModal" class="glyphicon glyphicon-file" th:attr="data-object-id=${primeiroPedido[5]}" th:onclick="'defineCodigoPrimeiroPedido(\'' + ${primeiroPedido[5]} + '\');'"> </span>
                                                </a></td>
                                            </tr>
                                        </th:block>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </th:block>
        </div>
    </div>
    <!--   </form>  -->
    <a class="btn btn-voltar" href="home" role="button botao">Voltar</a>
</div>

  • What do you mean by parameter? What do you bring in this parametric?

  • @Requestparam String parametroBuscaFirst

  • Joyce would like to know what you want to return in Html with this parametric, what it brings, a value?

  • Leandrade thank you for trying to help me in this parameter he passed data from a previous managed to resolve correctly calling in html in which was my difficulty I leave here my answer and thank your attention!

1 answer

2

I leave my answer here :

<form method="GET" th:action="@{/acompanhamentoprimeiropedido}">
        <input class="form-control" name="parametroBuscaPrimeiroPedido" />
        <button type="submit" class="btn btn-info" style="width: 100%;">
            <i class="glyphicon glyphicon-search"></i>
        </button>
</form>

th:action a Thymeleaf class has to stay inside the form and I added a button to submit the name="parametroBuscaPrimeiroPedido".

Within this parameter I called data coming from a precedent , in my case I just wanted to display the information.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.