1. /*
  2. * Copyright 2002-2004 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.springframework.web.servlet.view;
  17. /**
  18. * Convenience subclass of UrlBasedViewResolver that supports InternalResourceView
  19. * (i.e. Servlets and JSPs), and subclasses like JstlView and TilesView.
  20. *
  21. * <p>The view class for all views generated by this resolver can be specified
  22. * via setViewClass. See UrlBasedViewResolver's javadocs for details.
  23. *
  24. * <p>BTW, it's good practice to put JSP files that just serve as views under
  25. * WEB-INF, to hide them from direct access (e.g. via a manually entered URL).
  26. * Only controllers will be able to access them then.
  27. *
  28. * <p>Note: When chaining ViewResolvers, a InternalResourceViewResolver always
  29. * needs to be last, as it will attempt to resolve any view name, no matter
  30. * whether the underlying resource actually exists.
  31. *
  32. * @author Juergen Hoeller
  33. * @since 17.02.2003
  34. * @see #setViewClass
  35. * @see #setPrefix
  36. * @see #setSuffix
  37. * @see #setRequestContextAttribute
  38. * @see InternalResourceView
  39. * @see JstlView
  40. * @see org.springframework.web.servlet.view.tiles.TilesView
  41. */
  42. public class InternalResourceViewResolver extends UrlBasedViewResolver {
  43. /**
  44. * Sets default viewClass to InternalResourceView.
  45. * @see #setViewClass
  46. */
  47. public InternalResourceViewResolver() {
  48. setViewClass(InternalResourceView.class);
  49. }
  50. /**
  51. * Requires InternalResourceView.
  52. * @see InternalResourceView
  53. */
  54. protected Class requiredViewClass() {
  55. return InternalResourceView.class;
  56. }
  57. }