'Not able to display the value of Model object attribute using Thymeleaf

Below is my controller and html using Spring boot with thymeleaf. I'm not able to display the text value "headers1". Please let me know if i'm missing something.

@GetMapping(value = "/tabsDetails1")
    @ResponseBody
    public String getTabsDetails1(@RequestParam String Id, Model m) {       
         m.addAttribute("headers","headers1");
        return "pages/enr :: tab-info";
    }

--AJAx Call to get data will call tabsDetails1------- On click of the button will call showTabsDetails and should show the data using thymeleaf.

function showTabsDetails(id) {
            
            var param = '?id=' + $("#id").val();

                $.ajax({
                    url : "tabsDetails1"+param,
                  //  method : 'GET',
                   // data : $form.serialize(),
                    success : function(response) {
                        $('#enrDiv').show();
                    }
                });
        } 

----enr HTML------

<div th:fragment="tab-info"  id="enrDiv" >
        <div class="panel panel-default">
          <div class="panel-heading"><b>TEST</b></div>
             <div class="panel-body">
             <h2 th:text="${headers}"></h2>
            </div>
         </div>
</div

Also I'm passing an object through fragment in to new Html and I dont see value on the text input with th:field attribute. Weird thing is i'm able to see the value with th:text but not with th:field

<div class="tab-content">
<div class="tab-pane fade" th:classappend="${barStat.first} ? 'show active'"  th:id="${h.key}" th:each="h, barStat: ${headers}">
                        <div th:if="${h.key} == 'MY_FORM'">
                             <div  th:replace="~{fragments/myForm :: myHtmlForm(id,${h.value}) }"></div>
                        </div>                           
                </div>
            </div> 

Below is myHtmlForm fragment code

   <div th:fragment="myHtmlForm(id,headers)">
    <div class="setup-content" id="step-5">
        <form  th:action="@{/saveForms}" th:id="${id}" method="post"  th:object="${headers}"  class="form-horizontal" >

         <p th:text="${headers.name}"></p>  

                    <div class="row form-row">
                        <div class="col-md-6 form-group">
                            <label class="control-label">* Name</label> 
                            <input type="text"  th:text="${headers.name}" class="form-control"> 
                            <!-- <span class="error style="display: none;"> Please enter a Name.</span> -->
                        </div>
                    </div>
                </form>
            </div>
        </div>
                


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source