Petclinic is RESTful.
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@321 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
705c1c6b03
commit
057f5f6880
|
|
@ -10,7 +10,7 @@ CREATE MEMORY TABLE OWNERS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WIT
|
|||
CREATE INDEX OWNERS_LAST_NAME ON OWNERS(LAST_NAME)
|
||||
CREATE MEMORY TABLE PETS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,NAME VARCHAR(30),BIRTH_DATE DATE,TYPE_ID INTEGER NOT NULL,OWNER_ID INTEGER NOT NULL,CONSTRAINT FK_PETS_OWNERS FOREIGN KEY(OWNER_ID) REFERENCES OWNERS(ID),CONSTRAINT FK_PETS_TYPES FOREIGN KEY(TYPE_ID) REFERENCES TYPES(ID))
|
||||
CREATE INDEX PETS_NAME ON PETS(NAME)
|
||||
CREATE MEMORY TABLE VISITS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,PET_ID INTEGER NOT NULL,VISIT_DATE DATE,DESCRIPTION VARCHAR(255),CONSTRAINT FK_VISITS_PETS FOREIGN KEY(PET_ID) REFERENCES PETS(ID))
|
||||
CREATE MEMORY TABLE VISITS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,PET_ID INTEGER NOT NULL,VISIT_DATE DATE,DESCRIPTION VARCHAR(255),CONSTRAINT FK_VISITS_PETS FOREIGN KEY(PET_ID) REFERENCES PETS(ID) ON DELETE CASCADE)
|
||||
CREATE INDEX VISITS_PET_ID ON VISITS(PET_ID)
|
||||
ALTER TABLE VETS ALTER COLUMN ID RESTART WITH 7
|
||||
ALTER TABLE SPECIALTIES ALTER COLUMN ID RESTART WITH 4
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
<dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp.jstl" rev="1.1.2" conf="compile->runtime"/>
|
||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1" conf="compile->compile"/>
|
||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.dbcp" rev="1.2.2.osgi" conf="compile->runtime"/>
|
||||
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="compile->runtime"/>
|
||||
<dependency org="org.apache.taglibs" name="com.springsource.org.apache.taglibs.standard" rev="1.1.2" conf="compile->runtime"/>
|
||||
<dependency org="org.aspectj" name="com.springsource.org.aspectj.weaver" rev="1.5.4" conf="compile->compile"/>
|
||||
<dependency org="org.hibernate" name="com.springsource.org.hibernate" rev="3.2.6.ga" conf="compile->compile"/>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@
|
|||
<attribute name="method" value="1" />
|
||||
<attribute name="URI" value="/WEB-INF/classes" />
|
||||
</containerElement>
|
||||
<containerElement type="library" level="module">
|
||||
<attribute name="method" value="1" />
|
||||
<attribute name="URI" value="/WEB-INF/lib" />
|
||||
<url>jar://$IVY_CACHE$/org.apache.taglibs/com.springsource.org.apache.taglibs.standard/1.1.2/com.springsource.org.apache.taglibs.standard-1.1.2.jar!/</url>
|
||||
</containerElement>
|
||||
</packaging>
|
||||
</configuration>
|
||||
</facet>
|
||||
|
|
@ -47,6 +52,7 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
|
@ -130,6 +136,15 @@
|
|||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$IVY_CACHE$/org.apache.taglibs/com.springsource.org.apache.taglibs.standard/1.1.2/com.springsource.org.apache.taglibs.standard-1.1.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
|
|
|||
|
|
@ -74,4 +74,9 @@ public interface Clinic {
|
|||
*/
|
||||
void storeVisit(Visit visit) throws DataAccessException;
|
||||
|
||||
/**
|
||||
* Deletes a <code>Pet</code> from the data store.
|
||||
*/
|
||||
void deletePet(int id) throws DataAccessException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import org.springframework.samples.petclinic.Vet;
|
|||
import org.springframework.samples.petclinic.Visit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
/**
|
||||
* Hibernate implementation of the Clinic interface.
|
||||
|
|
@ -86,4 +87,9 @@ public class HibernateClinic implements Clinic {
|
|||
sessionFactory.getCurrentSession().merge(visit);
|
||||
}
|
||||
|
||||
public void deletePet(int id) throws DataAccessException {
|
||||
Pet pet = loadPet(id);
|
||||
sessionFactory.getCurrentSession().delete(pet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,6 +240,10 @@ public class SimpleJdbcClinic implements Clinic, SimpleJdbcClinicMBean {
|
|||
}
|
||||
}
|
||||
|
||||
public void deletePet(int id) throws DataAccessException {
|
||||
this.simpleJdbcTemplate.update("DELETE FROM pets WHERE id=?", id);
|
||||
}
|
||||
|
||||
// END of Clinic implementation section ************************************
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.springframework.samples.petclinic.Vet;
|
|||
import org.springframework.samples.petclinic.Visit;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
/**
|
||||
* JPA implementation of the Clinic interface using EntityManager.
|
||||
|
|
@ -87,4 +88,9 @@ public class EntityManagerClinic implements Clinic {
|
|||
visit.setId(merged.getId());
|
||||
}
|
||||
|
||||
public void deletePet(int id) throws DataAccessException {
|
||||
Pet pet = loadPet(id);
|
||||
this.em.remove(pet);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ import org.springframework.web.bind.WebDataBinder;
|
|||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/addOwner.do")
|
||||
@RequestMapping("/owners/new")
|
||||
@SessionAttributes(types = Owner.class)
|
||||
public class AddOwnerForm {
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ public class AddOwnerForm {
|
|||
else {
|
||||
this.clinic.storeOwner(owner);
|
||||
status.setComplete();
|
||||
return "redirect:owner.do?ownerId=" + owner.getId();
|
||||
return "redirect:/clinic/owners/" + owner.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
|
||||
|
|
@ -26,9 +27,10 @@ import org.springframework.web.bind.WebDataBinder;
|
|||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/addPet.do")
|
||||
@RequestMapping("/owners/{ownerId}/pets/new")
|
||||
@SessionAttributes("pet")
|
||||
public class AddPetForm {
|
||||
|
||||
|
|
@ -50,7 +52,7 @@ public class AddPetForm {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(@RequestParam("ownerId") int ownerId, Model model) {
|
||||
public String setupForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||
Owner owner = this.clinic.loadOwner(ownerId);
|
||||
Pet pet = new Pet();
|
||||
owner.addPet(pet);
|
||||
|
|
@ -67,7 +69,7 @@ public class AddPetForm {
|
|||
else {
|
||||
this.clinic.storePet(pet);
|
||||
status.setComplete();
|
||||
return "redirect:owner.do?ownerId=" + pet.getOwner().getId();
|
||||
return "redirect:/clinic/owners/" + pet.getOwner().getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
|
||||
|
|
@ -23,9 +24,10 @@ import org.springframework.web.bind.WebDataBinder;
|
|||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/addVisit.do")
|
||||
@RequestMapping("/owners/*/pets/{petId}/visits/new")
|
||||
@SessionAttributes("visit")
|
||||
public class AddVisitForm {
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ public class AddVisitForm {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(@RequestParam("petId") int petId, Model model) {
|
||||
public String setupForm(@PathVariable("petId") int petId, Model model) {
|
||||
Pet pet = this.clinic.loadPet(petId);
|
||||
Visit visit = new Visit();
|
||||
pet.addVisit(visit);
|
||||
|
|
@ -59,7 +61,7 @@ public class AddVisitForm {
|
|||
else {
|
||||
this.clinic.storeVisit(visit);
|
||||
status.setComplete();
|
||||
return "redirect:owner.do?ownerId=" + visit.getPet().getOwner().getId();
|
||||
return "redirect:/clinic/owners/" + visit.getPet().getOwner().getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import org.springframework.stereotype.Controller;
|
|||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* Annotation-driven <em>MultiActionController</em> that handles all non-form
|
||||
|
|
@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
* @author Juergen Hoeller
|
||||
* @author Mark Fisher
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
public class ClinicController {
|
||||
|
|
@ -34,7 +37,7 @@ public class ClinicController {
|
|||
* determine the logical view name based on the request URL: "/welcome.do"
|
||||
* -> "welcome".
|
||||
*/
|
||||
@RequestMapping("/welcome.do")
|
||||
@RequestMapping("/welcome")
|
||||
public void welcomeHandler() {
|
||||
}
|
||||
|
||||
|
|
@ -48,25 +51,22 @@ public class ClinicController {
|
|||
*
|
||||
* @return a ModelMap with the model attributes for the view
|
||||
*/
|
||||
@RequestMapping("/vets.do")
|
||||
@RequestMapping("/vets")
|
||||
public ModelMap vetsHandler() {
|
||||
return new ModelMap(this.clinic.getVets());
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom handler for displaying an owner.
|
||||
* <p>
|
||||
* Note that this handler returns a plain {@link ModelMap} object instead of
|
||||
* a ModelAndView, thus leveraging convention-based model attribute names.
|
||||
* It relies on the RequestToViewNameTranslator to determine the logical
|
||||
* view name based on the request URL: "/owner.do" -> "owner".
|
||||
*
|
||||
* @param ownerId the ID of the owner to display
|
||||
* @return a ModelMap with the model attributes for the view
|
||||
*/
|
||||
@RequestMapping("/owner.do")
|
||||
public ModelMap ownerHandler(@RequestParam("ownerId") int ownerId) {
|
||||
return new ModelMap(this.clinic.loadOwner(ownerId));
|
||||
@RequestMapping("/owners/{ownerId}")
|
||||
public ModelAndView ownerHandler(@PathVariable("ownerId") int ownerId) {
|
||||
ModelAndView mav = new ModelAndView("owner");
|
||||
mav.addObject(this.clinic.loadOwner(ownerId));
|
||||
return mav;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
|
||||
|
|
@ -21,9 +22,10 @@ import org.springframework.web.bind.WebDataBinder;
|
|||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/editOwner.do")
|
||||
@RequestMapping("/owners/{ownerId}/edit")
|
||||
@SessionAttributes(types = Owner.class)
|
||||
public class EditOwnerForm {
|
||||
|
||||
|
|
@ -40,7 +42,7 @@ public class EditOwnerForm {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(@RequestParam("ownerId") int ownerId, Model model) {
|
||||
public String setupForm(@PathVariable("ownerId") int ownerId, Model model) {
|
||||
Owner owner = this.clinic.loadOwner(ownerId);
|
||||
model.addAttribute(owner);
|
||||
return "ownerForm";
|
||||
|
|
@ -55,7 +57,7 @@ public class EditOwnerForm {
|
|||
else {
|
||||
this.clinic.storeOwner(owner);
|
||||
status.setComplete();
|
||||
return "redirect:owner.do?ownerId=" + owner.getId();
|
||||
return "redirect:/clinic/owners/" + owner.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.support.SessionStatus;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
|
||||
|
|
@ -24,9 +25,10 @@ import org.springframework.web.bind.WebDataBinder;
|
|||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/editPet.do")
|
||||
@RequestMapping("/owners/*/pets/{petId}")
|
||||
@SessionAttributes("pet")
|
||||
public class EditPetForm {
|
||||
|
||||
|
|
@ -48,7 +50,7 @@ public class EditPetForm {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String setupForm(@RequestParam("petId") int petId, Model model) {
|
||||
public String setupForm(@PathVariable("petId") int petId, Model model) {
|
||||
Pet pet = this.clinic.loadPet(petId);
|
||||
model.addAttribute("pet", pet);
|
||||
return "petForm";
|
||||
|
|
@ -63,8 +65,15 @@ public class EditPetForm {
|
|||
else {
|
||||
this.clinic.storePet(pet);
|
||||
status.setComplete();
|
||||
return "redirect:owner.do?ownerId=" + pet.getOwner().getId();
|
||||
return "redirect:/clinic/owners/" + pet.getOwner().getId();
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.DELETE)
|
||||
public String deletePet(@PathVariable int petId) {
|
||||
Pet pet = this.clinic.loadPet(petId);
|
||||
this.clinic.deletePet(petId);
|
||||
return "redirect:/clinic/owners/" + pet.getOwner().getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ import org.springframework.web.bind.WebDataBinder;
|
|||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Ken Krebs
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/findOwners.do")
|
||||
public class FindOwnersForm {
|
||||
|
||||
private final Clinic clinic;
|
||||
|
|
@ -36,13 +36,13 @@ public class FindOwnersForm {
|
|||
dataBinder.setDisallowedFields(new String[] {"id"});
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/owners/form", method = RequestMethod.GET)
|
||||
public String setupForm(Model model) {
|
||||
model.addAttribute("owner", new Owner());
|
||||
return "findOwners";
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/owners", method = RequestMethod.GET)
|
||||
public String processSubmit(Owner owner, BindingResult result, Model model) {
|
||||
// find owners by last name
|
||||
Collection<Owner> results = this.clinic.findOwners(owner.getLastName());
|
||||
|
|
@ -59,7 +59,7 @@ public class FindOwnersForm {
|
|||
else {
|
||||
// 1 owner found
|
||||
owner = results.iterator().next();
|
||||
return "redirect:owner.do?ownerId=" + owner.getId();
|
||||
return "redirect:/clinic/owners/" + owner.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
welcome=Welcome
|
||||
required=is required
|
||||
notFound=has not been found
|
||||
duplicate=is already in use
|
||||
nonNumeric=must be all numeric
|
||||
duplicateFormSubmission=Duplicate form submission is not allowed
|
||||
typeMismatch.date=invalid date
|
||||
typeMismatch.birthDate=invalid date
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
welcome=Willkommen
|
||||
required=muss angegeben werden
|
||||
notFound=wurde nicht gefunden
|
||||
duplicate=ist bereits vergeben
|
||||
nonNumeric=darf nur numerisch sein
|
||||
duplicateFormSubmission=Wiederholtes Absenden des Formulars ist nicht erlaubt
|
||||
typeMismatch.date=ungültiges Datum
|
||||
typeMismatch.birthDate=ungültiges Datum
|
||||
|
|
@ -0,0 +1 @@
|
|||
# This file is intentionally empty. Message look-ups will fall back to the default "messages.properties" file.
|
||||
|
|
@ -14,6 +14,6 @@ ex.printStackTrace(new java.io.PrintWriter(out));
|
|||
|
||||
<p/>
|
||||
<br/>
|
||||
<a href="<c:url value="/welcome.do"/>">Home</a>
|
||||
<a href="<spring:url value="/welcome.do"/>">Home</a>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
<h2>Find Owners:</h2>
|
||||
|
||||
<form:form modelAttribute="owner">
|
||||
<spring:url value="/clinic/owners" var="formUrl"/>
|
||||
<form:form modelAttribute="owner" action="${formUrl}" method="GET">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Last Name: <form:errors path="*" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="lastName" size="30" maxlength="80"/>
|
||||
<form:input path="lastName" size="30" maxlength="80" />
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -19,6 +20,6 @@
|
|||
</form:form>
|
||||
|
||||
<br/>
|
||||
<a href="<c:url value="/addOwner.do"/>">Add Owner</a>
|
||||
<a href='<spring:url value="/clinic/owners/new"/>'>Add Owner</a>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
<table class="footer">
|
||||
<tr>
|
||||
<td><a href="<c:url value="/welcome.do"/>">Home</a></td>
|
||||
<td align="right"><img src="<c:url value="/images/springsource-logo.png"/>"/></td>
|
||||
<td><a href="<spring:url value="/clinic/welcome"/>">Home</a></td>
|
||||
<td align="right"><img src="<spring:url value="/images/springsource-logo.png"/>" alt="Sponsored by SpringSource"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<link rel="stylesheet" href="<c:url value="/styles/petclinic.css"/>" type="text/css"/>
|
||||
<link rel="stylesheet" href="<spring:url value="/styles/petclinic.css"/>" type="text/css"/>
|
||||
<title>PetClinic :: a Spring Framework demonstration</title>
|
||||
</head>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,16 +24,10 @@
|
|||
<table class="table-buttons">
|
||||
<tr>
|
||||
<td colspan="2" align="center">
|
||||
<form method="GET" action="<c:url value="/editOwner.do"/>">
|
||||
<input type="hidden" name="ownerId" value="${owner.id}"/>
|
||||
<p class="submit"><input type="submit" value="Edit Owner"/></p>
|
||||
</form>
|
||||
<a href="<spring:url value="${owner.id}/edit"/>">Edit Owner</a>
|
||||
</td>
|
||||
<td>
|
||||
<form method="GET" action="<c:url value="/addPet.do"/>" name="formAddPet">
|
||||
<input type="hidden" name="ownerId" value="${owner.id}"/>
|
||||
<p class="submit"><input type="submit" value="Add New Pet"/></p>
|
||||
</form>
|
||||
<a href="<spring:url value="${owner.id}/pets/new"/>">Add New Pet</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -80,16 +74,17 @@
|
|||
<table class="table-buttons">
|
||||
<tr>
|
||||
<td>
|
||||
<form method="GET" action="<c:url value="/editPet.do"/>" name="formEditPet${pet.id}">
|
||||
<input type="hidden" name="petId" value="${pet.id}"/>
|
||||
<p class="submit"><input type="submit" value="Edit Pet"/></p>
|
||||
</form>
|
||||
<spring:url value="${owner.id}/pets/{petId}" var="petUrl">
|
||||
<spring:param name="petId" value="${pet.id}"/>
|
||||
</spring:url>
|
||||
<a href="${petUrl}">Edit Pet</a>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<form method="GET" action="<c:url value="/addVisit.do"/>" name="formVisitPet${pet.id}">
|
||||
<input type="hidden" name="petId" value="${pet.id}"/>
|
||||
<p class="submit"><input type="submit" value="Add Visit"/></p>
|
||||
</form>
|
||||
<spring:url value="${owner.id}/pets/{petId}/visits/new" var="visitUrl">
|
||||
<spring:param name="petId" value="${pet.id}"/>
|
||||
</spring:url>
|
||||
<a href="${visitUrl}">Add Visit</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@
|
|||
<c:forEach var="owner" items="${selections}">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="owner.do?ownerId=${owner.id}">${owner.firstName} ${owner.lastName}</a>
|
||||
<spring:url value="owners/{ownerId}" var="ownerUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
</spring:url>
|
||||
<a href="${ownerUrl}">${owner.firstName} ${owner.lastName}</a>
|
||||
</td>
|
||||
<td>${owner.address}</td>
|
||||
<td>${owner.city}</td>
|
||||
|
|
|
|||
|
|
@ -44,4 +44,10 @@
|
|||
</table>
|
||||
</form:form>
|
||||
|
||||
<c:if test="${!pet.new}">
|
||||
<form:form method="DELETE">
|
||||
<p class="submit"><input type="submit" value="Delete Pet"/></p>
|
||||
</form:form>
|
||||
</c:if>
|
||||
|
||||
<%@ include file="/WEB-INF/jsp/footer.jsp" %>
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
<%@ include file="/WEB-INF/jsp/header.jsp" %>
|
||||
|
||||
<img src="images/pets.png" align="right" style="position:relative;right:30px;">
|
||||
<img src="<spring:url value="/images/pets.png"/>" align="right" style="position:relative;right:30px;">
|
||||
<h2><fmt:message key="welcome"/></h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="<c:url value="/findOwners.do"/>">Find owner</a></li>
|
||||
<li><a href="<c:url value="/vets.do"/>">Display all veterinarians</a></li>
|
||||
<li><a href="<c:url value="/html/petclinic.html"/>">Tutorial</a></li>
|
||||
<li><a href="<c:url value="/docs/index.html"/>">Documentation</a></li>
|
||||
<li><a href="<spring:url value="/clinic/owners/form"/>">Find owner</a></li>
|
||||
<li><a href="<spring:url value="/clinic/vets"/>">Display all veterinarians</a></li>
|
||||
<li><a href="<spring:url value="/html/petclinic.html"/>">Tutorial</a></li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
|
|
|
|||
|
|
@ -110,9 +110,19 @@
|
|||
-->
|
||||
<servlet-mapping>
|
||||
<servlet-name>petclinic</servlet-name>
|
||||
<url-pattern>*.do</url-pattern>
|
||||
<url-pattern>/clinic/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<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>
|
||||
|
||||
<session-config>
|
||||
<session-timeout>10</session-timeout>
|
||||
</session-config>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<%@ include file="/WEB-INF/jsp/includes.jsp" %>
|
||||
|
||||
<%-- Redirected because we can't set the welcome page to a virtual URL. --%>
|
||||
<c:redirect url="/welcome.do"/>
|
||||
<c:redirect url="/clinic/welcome"/>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue