Package net.solarnetwork.web.support
Class WebUtils
java.lang.Object
net.solarnetwork.web.support.WebUtils
Common utility helper methods for web processing.
- Version:
- 1.0
- Author:
- matt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringresolveViewFromUrlExtension(javax.servlet.http.HttpServletRequest request, String viewName) Resolve a ModelAndView with an empty model and a view name determined by the URL "suffix".
-
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.jsonwould resolve to a view namedjson. This can be handy when you want to return different data formats for the same business logic, such as XML or JSON.The
viewNameparameter can be used to override the view mapping logic and instead simply return aModelAndViewobject 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 requestviewName- the custom view name- Returns:
- a view name (never null)
-