mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 20:35:49 +00:00
Spring MVC config and layout in 'vets' section
- commented out all Spring MVC config related to content negociation so the app works well in HTML for now - Integrated Bootsrap look&Feel in the 'vets' section
This commit is contained in:
parent
9a77b56427
commit
099847cf49
5 changed files with 82 additions and 91 deletions
|
@ -10,11 +10,9 @@
|
|||
<jsp:include page="../header.jsp"/>
|
||||
|
||||
<body>
|
||||
<div id="header well">
|
||||
<div class="container" style="padding-top: 50px;">
|
||||
<spring:url value="/resources/images/banner-graphic.png" var="banner"/>
|
||||
<img src="${banner}" />
|
||||
</div>
|
||||
<div class="container" style="padding-top: 50px;">
|
||||
<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>
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
<table class="table-buttons">
|
||||
<tr>
|
||||
<td>
|
||||
<spring:url value="{ownerId}/pets/{petId}/edit" var="petUrl">
|
||||
<spring:url value="/owners/{ownerId}/pets/{petId}/edit" var="petUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:param name="petId" value="${pet.id}"/>
|
||||
</spring:url>
|
||||
|
@ -100,7 +100,7 @@
|
|||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<spring:url value="{ownerId}/pets/{petId}/visits/new" var="visitUrl">
|
||||
<spring:url value="/owners/{ownerId}/pets/{petId}/visits/new" var="visitUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:param name="petId" value="${pet.id}"/>
|
||||
</spring:url>
|
||||
|
@ -108,7 +108,7 @@
|
|||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
<spring:url value="{ownerId}/pets/{petId}/visits.atom" var="feedUrl">
|
||||
<spring:url value="/owners/{ownerId}/pets/{petId}/visits.atom" var="feedUrl">
|
||||
<spring:param name="ownerId" value="${owner.id}"/>
|
||||
<spring:param name="petId" value="${pet.id}"/>
|
||||
</spring:url>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<div class="container">
|
||||
<spring:url value="/resources/images/banner-graphic.png" var="banner"/>
|
||||
<img src="${banner}" />
|
||||
|
||||
<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>
|
||||
|
@ -22,49 +23,42 @@
|
|||
<b>Owner:</b> ${pet.owner.firstName} ${pet.owner.lastName}
|
||||
<br/>
|
||||
<form:form modelAttribute="pet" method="${method}">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Name: <form:errors path="name" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="name" size="30" maxlength="30"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Birth Date: <form:errors path="birthDate" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:input path="birthDate" size="10" maxlength="10"/> (yyyy-mm-dd)
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Type: <form:errors path="type" cssClass="errors"/>
|
||||
<br/>
|
||||
<form:select path="type" items="${types}"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${pet['new']}">
|
||||
<p class="submit"><input type="submit" value="Add Pet"/></p>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<p class="submit"><input type="submit" value="Update Pet"/></p>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
</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>
|
||||
|
||||
<fieldset>
|
||||
<div class="control-group" id="name">
|
||||
<label class="control-label">Name </label>
|
||||
<div class="controls">
|
||||
<form:input path="name" />
|
||||
<span class="help-inline"><form:errors path="name" /></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" id="birthDate">
|
||||
<label class="control-label">Birth Date </label>
|
||||
<div class="controls">
|
||||
<form:input path="birthDate" />
|
||||
<span class="help-inline"><form:errors path="birthDate" /></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" id="type">
|
||||
<label class="control-label">Type </label>
|
||||
<form:select path="type" items="${types}"/>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<c:choose>
|
||||
<c:when test="${owner['new']}">
|
||||
<button type="submit">Add Pet</button>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<button type="submit">Update Pet</button>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
</fieldset>
|
||||
</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>
|
||||
</div>
|
||||
<jsp:include page="../footer.jsp"/>
|
||||
</body>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<h2>Veterinarians</h2>
|
||||
|
||||
<table>
|
||||
<table class="table table-stripped" style="width:600px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
@ -44,8 +44,8 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<jsp:include page="footer.jsp"/>
|
||||
</div>
|
||||
<jsp:include page="footer.jsp"/>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -15,22 +15,41 @@
|
|||
-->
|
||||
<context:component-scan base-package="org.springframework.samples.petclinic.web"/>
|
||||
|
||||
<!--
|
||||
- The form-based controllers within this application provide @RequestMapping
|
||||
- annotations at the type level for path mapping URLs and @RequestMapping
|
||||
- at the method level for request type mappings (e.g., GET and POST).
|
||||
- In contrast, ClinicController - which is not form-based - provides
|
||||
- @RequestMapping only at the method level for path mapping URLs.
|
||||
-
|
||||
- DefaultAnnotationHandlerMapping is driven by these annotations and is
|
||||
- enabled by default with Java 5+.
|
||||
-->
|
||||
|
||||
<mvc:annotation-driven />
|
||||
<!-- <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" /> -->
|
||||
|
||||
<!-- all resources inside folder src/main/webapp/resources are mapped so they can be refered to inside JSP files
|
||||
(see header.jsp for more details) -->
|
||||
<mvc:resources mapping="/resources/**" location="/resources/"/>
|
||||
|
||||
<!-- uses WebJars so Javascript and CSS libs can be declared as Maven dependencies (we're using it for Bootstrap) -->
|
||||
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
|
||||
|
||||
|
||||
<!--
|
||||
- This bean processes annotated handler methods, applying PetClinic-specific PropertyEditors
|
||||
- for request parameter binding. It overrides the default AnnotationMethodHandlerAdapter.
|
||||
|
||||
- This bean configures the 'prefix' and 'suffix' properties of
|
||||
- InternalResourceViewResolver, which resolves logical view names
|
||||
- returned by Controllers. For example, a logical view name of "vets"
|
||||
- will be mapped to "/WEB-INF/jsp/vets.jsp".
|
||||
-->
|
||||
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/"
|
||||
p:suffix=".jsp" />
|
||||
|
||||
<!--
|
||||
- Message source for this context, loaded from localized "messages_xx" files.
|
||||
- Files are stored inside src/main/resources
|
||||
-->
|
||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
|
||||
p:basename="messages"/>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
Processes annotated handler methods, applying PetClinic-specific request parameter binding.
|
||||
-->
|
||||
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
|
||||
<property name="webBindingInitializer">
|
||||
<bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer"/>
|
||||
</property>
|
||||
|
@ -61,14 +80,9 @@
|
|||
- property of the vets view bean, setting it to 'application/vnd.springsource.samples.petclinic+xml'.
|
||||
-->
|
||||
|
||||
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
|
||||
|
||||
<mvc:resources mapping="/resources/**" location="/resources/"/>
|
||||
|
||||
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
|
||||
|
||||
|
||||
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||||
<!-- <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||||
<property name="favorPathExtension" value="false" />
|
||||
<property name="favorParameter" value="true" />
|
||||
<property name="mediaTypes">
|
||||
|
@ -78,7 +92,7 @@
|
|||
xml=application/xml
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
</bean> -->
|
||||
|
||||
|
||||
<!--
|
||||
|
@ -87,21 +101,12 @@
|
|||
- be the first view resolver to be used after the delegating content
|
||||
- negotiating view resolver.
|
||||
-->
|
||||
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
|
||||
<!--
|
||||
|
||||
- This bean configures the 'prefix' and 'suffix' properties of
|
||||
- InternalResourceViewResolver, which resolves logical view names
|
||||
- returned by Controllers. For example, a logical view name of "vets"
|
||||
- will be mapped to "/WEB-INF/jsp/vets.jsp".
|
||||
-->
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/"
|
||||
p:suffix=".jsp" />
|
||||
<!-- <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> -->
|
||||
|
||||
|
||||
<!-- - The AtomView rendering a Atom feed of the visits -->
|
||||
|
||||
<bean id="visits" class="org.springframework.samples.petclinic.web.VisitsAtomView"/>
|
||||
<!-- <bean id="visits" class="org.springframework.samples.petclinic.web.VisitsAtomView"/>
|
||||
|
||||
<bean id="vets" class="org.springframework.web.servlet.view.xml.MarshallingView">
|
||||
<property name="contentType" value="application/vnd.springsource.samples.petclinic+xml"/>
|
||||
|
@ -110,14 +115,8 @@
|
|||
|
||||
<oxm:jaxb2-marshaller id="marshaller">
|
||||
<oxm:class-to-be-bound name="org.springframework.samples.petclinic.Vets"/>
|
||||
</oxm:jaxb2-marshaller>
|
||||
</oxm:jaxb2-marshaller> -->
|
||||
|
||||
|
||||
<!--
|
||||
- Message source for this context, loaded from localized "messages_xx" files.
|
||||
- Could also reside in the root application context, as it is generic,
|
||||
- but is currently just used within PetClinic's web tier.
|
||||
-->
|
||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
|
||||
p:basename="messages"/>
|
||||
|
||||
</beans>
|
||||
|
|
Loading…
Reference in a new issue