1

I am trying to do a call to my REST service to create a supplier. I need the itemCode of the supplied item and the username that wants to create it. Right now, i am call it like this:

th:href="@{/api/supplier/getSupplierViewItem/{username}(username = ${username})/{itemCode}(itemCode = ${item.itemCode})}

Then, my controller should get that petition:

    @GetMapping("/getSupplierViewItem/{username:.+}/{itemCode:.+}")
    public String getSupplierViewwithItem(@PathVariable("username")String username, @PathVariable("itemCode") String itemCode, ModelMap model){
        model.addAttribute("username", username);
        model.addAttribute("itemCode", itemCode);
        return "createSupplier";
    }

However, when I try it, I get this following petition:

http://localhost:8080/api/supplier/getSupplierViewItem/%7Busername%7D(username%20=%20$%7Busername%7D)/01231

Basically, instead of the value of username, I´m getting

{username}(username = ${username})

Which is the best way to send both parameters?

1 Answer 1

2

The correct syntax for your url is:

th:href="@{/api/supplier/getSupplierViewItem/{username}/{itemCode}(username=${username},itemCode=${item.itemCode})}"

See the standard url syntax for multiple parameters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.