इम यह त्रुटि मिलती: HTTP Status 405 - Request method 'POST' not supported
HTTP स्थिति 405 अनुरोध 'POST' समर्थित नहीं (वसंत MVC)
मैं क्या करने की कोशिश कर रहा हूँ कि अन्य के आधार पर आबादी वाले हो ड्रॉप-डाउन बॉक्स के साथ एक फार्म बनाने के है मूल्य एक और ड्रॉप डाउन बॉक्स में चुना गया। उदाहरण के लिए जब मैं customerName
बॉक्स में onChange
फ़ंक्शन में कोई नाम चुनता हूं तो .jsp पृष्ठ में फ़ंक्शन चलाया जाना चाहिए और फिर सबमिट किया गया पृष्ठ customerCountry
बॉक्स में संबंधित मानों के साथ फिर से लोड किया जाना चाहिए।
हालांकि मुझे यह HTTP स्थिति 405 त्रुटि मिल रही है। मैंने समाधान के लिए इंटरनेट की खोज की है लेकिन मदद की कोई भी चीज़ नहीं मिली है।
jsp पृष्ठ के भाग के नियंत्रक के
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
.error { color: red; }
</style>
<script>
function repopulate(){
document.deliveryForm.submit();
}
function setFalse(){
document.getElementById("hasId").value ="false";
document.deliveryForm.submit();
// document.submitForm.submit(); (This was causing the error)
}
</script>
</head>
<body>
<h1>Create New Delivery</h1>
<c:url var="saveUrl" value="/test/delivery/add" />
<form:form modelAttribute="deliveryDtoAttribute" method="POST" action="${saveUrl}" name="deliveryForm">
<table>
<tr>
<td><form:hidden id="hasId" path="hasCustomerName" value="true"/></td>
</tr>
<tr>
<td>Customer Name</td>
<td><form:select path="customerName" onChange="repopulate()">
<form:option value="" label="--- Select ---" />
<form:options items="${customerNameList}" />
</form:select>
</td>
<td><form:errors path="customerName" cssClass="error" /></td>
</tr>
<tr>
<td>Customer Country</td>
<td><form:select path="customerCountry">
<form:option value="" label="--- Select ---" />
<form:options items="${customerCountryList}" />
</form:select>
</td>
<td><form:errors path="customerCountry" cssClass="error" /></td>
</tr>
</form:form>
<form:form name="submitForm">
<input type="button" value="Save" onClick="setFalse()"/>
</form:form>
</body>
</html>
हिस्सा:
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String getDelivery(ModelMap model) {
DeliveryDto deliveryDto = new DeliveryDto();
model.addAttribute("deliveryDtoAttribute", deliveryDto);
model.addAttribute("customerNameList",
customerService.listAllCustomerNames());
model.addAttribute("customerCountryList", customerService
.listAllCustomerCountries(deliveryDto.getCustomerName()));
return "new-delivery";
}
// I want to enter this method if hasId=true which means that a value in the CustomerName
// drop down list was selected. This should set the CountryList to the corresponding values
// from the database. I want this post method to be triggered by the onChange in the jsp page
@RequestMapping(value = "/add", method = RequestMethod.POST, params="hasCustomerName=true")
public String postDelivery(
@ModelAttribute("deliveryDtoAttribute") DeliveryDto deliveryDto,
BindingResult result, ModelMap model) {
model.addAttribute("deliveryDtoAttribute", deliveryDto);
model.addAttribute("customerNameList",
customerService.listAllCustomerNames());
model.addAttribute("customerCountryList", customerService
.listAllCustomerCountries(deliveryDto.getCustomerName()));
return "new-delivery";
}
// This next post method should only be entered if the save button is hit in the jsp page
@RequestMapping(value = "/add", method = RequestMethod.POST, params="hasCustomerName=false")
public String postDelivery2(
@ModelAttribute("deliveryDtoAttribute") @Valid DeliveryDto deliveryDto,
BindingResult result, ModelMap model) {
if (result.hasErrors()) {
model.addAttribute("deliveryDtoAttribute", deliveryDto);
model.addAttribute("customerNameList",
customerService.listAllCustomerNames());
model.addAttribute("customerCountryList", customerService
.listAllCustomerCountries(deliveryDto.getCustomerName()));
return "new-delivery";
} else {
Delivery delivery = new Delivery();
//Setters to set delivery values
return "redirect:/mis/home";
}
}
मैं इस त्रुटि को कैसे मिल आओ यहाँ मेरी कोड के प्रासंगिक भागों है? कोई भी सहायताकाफी प्रशंसनीय होगी! धन्यवाद
संपादित करें:hasCustomerName
को hasId
बदल दिया है। मुझे अभी भी HTTP Status 405 - Request method 'POST' not supported
त्रुटि मिलती है।
EDIT2:setFalse
समारोह में लाइन है कि त्रुटि
// डी
मतदान क्यों करें? कृपया मुझे एक स्पष्टीकरण प्रदान करें ताकि मैं भविष्य में बेहतर प्रश्न पोस्ट कर सकूं। इस समस्या को मारने और इस पृष्ठ पर आने वाले लोगों के लिए धन्यवाद – dlinx90
, यह भी जांचें कि परिभाषित कार्रवाई मौजूदा अंतराल को हिट करती है, यह मेरी समस्या थी :) –