Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

html - Having issues passing placeholder value in Thymeleaf to URL

I am new to Thymeleaf. I am having an issue taking the place holder value from the user(frontend) and storing it into my Url. I am trying to take the id value from the user and using findById operation to search the database and render the information to the browser. But when I manually enter the id number in the url it finds the customer.

Controller


    @GetMapping("/withdrawal")
    public String withdrawal(Model model) {
        CheckingAccount checkingAccount = new CheckingAccount();
        model.addAttribute("checkingAccount", checkingAccount);
        return "find_checking_account";
    }

    @GetMapping("/findcheckingaccount/{id}")
    public String getAccount(@PathVariable("id") Integer checkingId, Model model) {
        CheckingAccount checkingAccount = checkingService.getAccount(checkingId);
        model.addAttribute("checkingAccount", checkingAccount);
        return "Found_checking_account";
    }

Html

<body>
<div class="container 2">
    <h1>Find Checking Account</h1>
    <hr>
    <form action = "#" th:action="@{/findcheckingaccount/{Id}(Id=${checkingId})}" method="get">

        <div>
        <a th:if{checkingAccount}>

        <input type="number" th:field="*{checkingAccount.checkingId}" placeholder="Enter Account Id" class="form-control mb-4 col-4">

        <button type="submit" class="btn btn-info col-2"> Find </button>
        </a>
        </div>
    </form>
</div>
</body>

Error message enter image description here

Manually entering the id number it works !! enter image description here

question from:https://stackoverflow.com/questions/65840092/having-issues-passing-placeholder-value-in-thymeleaf-to-url

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...