-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.com
Description
My controller for POST Method
/**
* POST an order
* @param order
*/
@RequestMapping(method = RequestMethod.POST, value = "/orders/add")
public String addOrders(@RequestBody Orders order, BindingResult bindingResult) {
System.out.println();
System.out.println("************");
System.out.println();
if(bindingResult.hasErrors()){
return "addOrder";
}
orderService.addOrder(order);
return "redirect:/orders/"+order.getOrderId();
}
I'm Sure no issue in the above code as the control doesn't reach here.
My HTML page where form is present: index.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Welcome</title>
<style>
h1 {
text-align: center;
}
</style>
</head>
<body>
<h1>I am a welcome message</h1>
<p>Lets hope Thymeleaf runs without web.xml</p>
<form th:action="@{/orders/add}" th:object="${orders}" method="post">
<p>Product: <input type="text" th:field="*{product}" /></p>
<p>Description <input type="text" th:field="*{description}" /></p>
<p>Quantity <input type="text" th:field="*{quantity}" /></p>
<p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
</form>
</body>
</html>
Orders class has attributes like product, description, quantity.
Error 405, bad request is generated. Need to know where i'm wrong.
Metadata
Metadata
Assignees
Labels
for: stackoverflowA question that's better suited to stackoverflow.comA question that's better suited to stackoverflow.com