Class WebUtils

java.lang.Object
net.solarnetwork.web.support.WebUtils

public final class WebUtils extends Object
Common utility helper methods for web processing.
Version:
1.0
Author:
matt
  • Constructor Details

    • WebUtils

      public WebUtils()
  • Method Details

    • resolveViewFromUrlExtension

      public static String resolveViewFromUrlExtension(javax.servlet.http.HttpServletRequest request, String viewName)
      Resolve a ModelAndView with an empty model and a view name determined by the URL "suffix".

      The resolved view name will be derived from the value of the URL "suffix", that is, everything after the last period in the URL. This uses StringUtils.getFilenameExtension(String) on the request URI to accomplish this. For example a URL like /myController.json would resolve to a view named json. This can be handy when you want to return different data formats for the same business logic, such as XML or JSON.

      The viewName parameter can be used to override the view mapping logic and instead simply return a ModelAndView object for the given name. For normal controllers with a configurable view name property, that property can be passed in here, but usually the value will not be configured.

      Parameters:
      request - the HTTP request
      viewName - the custom view name
      Returns:
      a view name (never null)