diff --git a/src/main/java/org/springframework/samples/petclinic/web/ClinicController.java b/src/main/java/org/springframework/samples/petclinic/web/ClinicController.java index 4ffcd7173..8d5ea2dd0 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/ClinicController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/ClinicController.java @@ -1,12 +1,20 @@ package org.springframework.samples.petclinic.web; +import java.text.SimpleDateFormat; +import java.util.Date; + import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.propertyeditors.CustomDateEditor; +import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.samples.petclinic.Clinic; +import org.springframework.samples.petclinic.PetType; import org.springframework.samples.petclinic.Vets; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/src/main/webapp/WEB-INF/jsp/dataAccessFailure.jsp b/src/main/webapp/WEB-INF/jsp/dataAccessFailure.jsp deleted file mode 100644 index 5674cabab..000000000 --- a/src/main/webapp/WEB-INF/jsp/dataAccessFailure.jsp +++ /dev/null @@ -1,30 +0,0 @@ -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> - - - - - - - -
- <% - Exception ex = (Exception) request.getAttribute("exception"); - %> - -

Data access failure: <%= ex.getMessage() %>

-

- - <% - ex.printStackTrace(new java.io.PrintWriter(out)); - %> - -

-
- ">Home - -

- - - - - diff --git a/src/main/webapp/WEB-INF/jsp/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception.jsp new file mode 100644 index 000000000..35bfc43e5 --- /dev/null +++ b/src/main/webapp/WEB-INF/jsp/exception.jsp @@ -0,0 +1,21 @@ + +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> + + + + +
+ + + + +

Something happened...

+

${exception.message}

+ + + + +
+ + + diff --git a/src/main/webapp/WEB-INF/jsp/uncaughtException.jsp b/src/main/webapp/WEB-INF/jsp/uncaughtException.jsp deleted file mode 100644 index 236a7b9b3..000000000 --- a/src/main/webapp/WEB-INF/jsp/uncaughtException.jsp +++ /dev/null @@ -1,64 +0,0 @@ -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - - - - - -
- -

Internal error

-

- - <% - try { - // The Servlet spec guarantees this attribute will be available - Throwable exception = (Throwable) request.getAttribute("javax.servlet.error.exception"); - - if (exception != null) { - if (exception instanceof ServletException) { - // It's a ServletException: we should extract the root cause - ServletException sex = (ServletException) exception; - Throwable rootCause = sex.getRootCause(); - if (rootCause == null) - rootCause = sex; - out.println("** Root cause is: "+ rootCause.getMessage()); - rootCause.printStackTrace(new java.io.PrintWriter(out)); - } - else { - // It's not a ServletException, so we'll just show it - exception.printStackTrace(new java.io.PrintWriter(out)); - } - } - else { - out.println("No error information available"); - } - - // Display cookies - out.println("\nCookies:\n"); - Cookie[] cookies = request.getCookies(); - if (cookies != null) { - for (int i = 0; i < cookies.length; i++) { - out.println(cookies[i].getName() + "=[" + cookies[i].getValue() + "]"); - } - } - - } catch (Exception ex) { - ex.printStackTrace(new java.io.PrintWriter(out)); - } - %> - -

-
- - -

- - - - - diff --git a/src/main/webapp/WEB-INF/petclinic-servlet.xml b/src/main/webapp/WEB-INF/petclinic-servlet.xml index 153fd456e..d203e4a1b 100644 --- a/src/main/webapp/WEB-INF/petclinic-servlet.xml +++ b/src/main/webapp/WEB-INF/petclinic-servlet.xml @@ -75,8 +75,6 @@ - - @@ -93,32 +91,10 @@ - here with all other types of exceptions. --> - - - pageNotFound - dataAccessFailure - dataAccessFailure - - - + - - - - - - - - - @@ -132,6 +108,4 @@ - -