Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

1
404 error while using Spring-boot RequestMapping with PathVariable

Open 1 Answers 347 Views Programming
1 1
Currently the application I am working on throws 404 error while using custom path.

 

e.g.

 

@Controller @RequestMapping(value = "/orderconfirmation") public class OrderConfirmationController {

.... .... ...

@RequestMapping(value = "{TId}",method = RequestMethod.GET) public String getOrderConfirmation(@PathVariable String TId, Model model) { .... some code here ... model.addAttribute("transaction",transaction); return "orderconfirmation"; }

... ... ...

}

 

It triggers the controller as during debug I can go through the controller. But after completion it throws 404 error. Any idea?

1 Answer

0
0

I guess batter option for you is to pass TId as URL parameters as below.

 

http://localhost/..yourwebapp../orderconfirmation?TId={your tid here}.

 

You can read in controller as given below.

 

@RequestMapping(method = RequestMethod.GET)
public String getOrderConfirmation(@RequestParam(value = "TId") String TId, Model model) {

//... ... ...

}

answered by (151 points)

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...