Skip to content

Commit

Permalink
Merge pull request spring-projects#99 from trepel/removalofputmethod
Browse files Browse the repository at this point in the history
Removed HTTP PUT method - it is not supported in JSP 2.3
  • Loading branch information
arey committed Oct 14, 2015
2 parents 8b5d980 + f7498c7 commit 566fdac
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public String initUpdateOwnerForm(@PathVariable("ownerId") int ownerId, Model mo
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) {
if (result.hasErrors()) {
return "owners/createOrUpdateOwnerForm";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public String initUpdateForm(@PathVariable("petId") int petId, Map<String, Objec
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) {
if (result.hasErrors()) {
return "pets/createOrUpdatePetForm";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
<body>
<div class="container">
<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>
<c:if test="${owner['new']}">New </c:if> Owner
</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="Last Name" name="lastName"/>
<petclinic:inputField label="Address" name="address"/>
Expand Down
10 changes: 1 addition & 9 deletions src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,13 @@
</script>
<div class="container">
<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>
<c:if test="${pet['new']}">New </c:if>
Pet
</h2>

<form:form modelAttribute="pet" method="${method}"
<form:form modelAttribute="pet"
class="form-horizontal">
<div class="control-group" id="owner">
<label class="control-label">Owner </label>
Expand Down
13 changes: 0 additions & 13 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,6 @@
<url-pattern>/*</url-pattern>
</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 -->
<filter>
<filter-name>datatables</filter-name>
Expand Down

0 comments on commit 566fdac

Please sign in to comment.