mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-21 11:29:38 +00:00
Removed HTTP PUT method - it is not supported in JSP 2.3
This commit is contained in:
parent
e0be3a39b6
commit
f7498c79df
5 changed files with 4 additions and 29 deletions
|
@ -116,7 +116,7 @@ public class OwnerController {
|
||||||
return "owners/createOrUpdateOwnerForm";
|
return "owners/createOrUpdateOwnerForm";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.PUT)
|
@RequestMapping(value = "/owners/{ownerId}/edit", method = RequestMethod.POST)
|
||||||
public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, SessionStatus status) {
|
public String processUpdateOwnerForm(@Valid Owner owner, BindingResult result, SessionStatus status) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
return "owners/createOrUpdateOwnerForm";
|
return "owners/createOrUpdateOwnerForm";
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class PetController {
|
||||||
return "pets/createOrUpdatePetForm";
|
return "pets/createOrUpdatePetForm";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
@RequestMapping(value = "/owners/{ownerId}/pets/{petId}/edit", method = RequestMethod.POST)
|
||||||
public String processUpdateForm(@Valid Pet pet, BindingResult result, SessionStatus status) {
|
public String processUpdateForm(@Valid Pet pet, BindingResult result, SessionStatus status) {
|
||||||
if (result.hasErrors()) {
|
if (result.hasErrors()) {
|
||||||
return "pets/createOrUpdatePetForm";
|
return "pets/createOrUpdatePetForm";
|
||||||
|
|
|
@ -15,15 +15,11 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<jsp:include page="../fragments/bodyHeader.jsp"/>
|
<jsp:include page="../fragments/bodyHeader.jsp"/>
|
||||||
<c:choose>
|
|
||||||
<c:when test="${owner['new']}"><c:set var="method" value="post"/></c:when>
|
|
||||||
<c:otherwise><c:set var="method" value="put"/></c:otherwise>
|
|
||||||
</c:choose>
|
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
<c:if test="${owner['new']}">New </c:if> Owner
|
<c:if test="${owner['new']}">New </c:if> Owner
|
||||||
</h2>
|
</h2>
|
||||||
<form:form modelAttribute="owner" method="${method}" class="form-horizontal" id="add-owner-form">
|
<form:form modelAttribute="owner" class="form-horizontal" id="add-owner-form">
|
||||||
<petclinic:inputField label="First Name" name="firstName"/>
|
<petclinic:inputField label="First Name" name="firstName"/>
|
||||||
<petclinic:inputField label="Last Name" name="lastName"/>
|
<petclinic:inputField label="Last Name" name="lastName"/>
|
||||||
<petclinic:inputField label="Address" name="address"/>
|
<petclinic:inputField label="Address" name="address"/>
|
||||||
|
|
|
@ -18,21 +18,13 @@
|
||||||
</script>
|
</script>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<jsp:include page="../fragments/bodyHeader.jsp"/>
|
<jsp:include page="../fragments/bodyHeader.jsp"/>
|
||||||
<c:choose>
|
|
||||||
<c:when test="${pet['new']}">
|
|
||||||
<c:set var="method" value="post"/>
|
|
||||||
</c:when>
|
|
||||||
<c:otherwise>
|
|
||||||
<c:set var="method" value="put"/>
|
|
||||||
</c:otherwise>
|
|
||||||
</c:choose>
|
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
<c:if test="${pet['new']}">New </c:if>
|
<c:if test="${pet['new']}">New </c:if>
|
||||||
Pet
|
Pet
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<form:form modelAttribute="pet" method="${method}"
|
<form:form modelAttribute="pet"
|
||||||
class="form-horizontal">
|
class="form-horizontal">
|
||||||
<div class="control-group" id="owner">
|
<div class="control-group" id="owner">
|
||||||
<label class="control-label">Owner </label>
|
<label class="control-label">Owner </label>
|
||||||
|
|
|
@ -98,19 +98,6 @@
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
<!-- used so we can use forms of method type 'PUT' and 'DELETE' (such as in the Pet form)
|
|
||||||
see here: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/view.html#rest-method-conversion
|
|
||||||
-->
|
|
||||||
<filter>
|
|
||||||
<filter-name>httpMethodFilter</filter-name>
|
|
||||||
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
|
|
||||||
</filter>
|
|
||||||
|
|
||||||
<filter-mapping>
|
|
||||||
<filter-name>httpMethodFilter</filter-name>
|
|
||||||
<servlet-name>petclinic</servlet-name>
|
|
||||||
</filter-mapping>
|
|
||||||
|
|
||||||
<!-- Dandelion-Datatables filter, used for basic export -->
|
<!-- Dandelion-Datatables filter, used for basic export -->
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>datatables</filter-name>
|
<filter-name>datatables</filter-name>
|
||||||
|
|
Loading…
Reference in a new issue