/**
* Looks for the StripesRequesetWrapper for the specific request and returns it. This is done
* by checking to see if the request is a StripesRequestWrapper, and if not, successively
* unwrapping the request until the StripesRequestWrapper is found.
*
* @param request the ServletRequest that is wrapped by a StripesRequestWrapper
* @return the StripesRequestWrapper that is wrapping the supplied request
* @throws IllegalStateException if the request is not wrapped by Stripes
*/
public static StripesRequestWrapper findStripesWrapper(ServletRequest request) {
// Loop through any request wrappers looking for the stripes one
while ( !(request instanceof StripesRequestWrapper)
&& request != null
&& request instanceof HttpServletRequestWrapper) {
request = ((HttpServletRequestWrapper) request).getRequest();
}
// If we have our wrapper after the loop exits, we're good; otherwise...
if (request instanceof StripesRequestWrapper) {
return (StripesRequestWrapper) request;
}
else {
throw new IllegalStateException(String.format("Request %s made it through to some part of Stripes " +
"without being wrapped in a StripesRequestWrapper. The StripesFilter is " +
"responsible for wrapping the request, so it is likely that either the " +
"StripesFilter is not deployed, or that its mappings do not include the " +
"DispatcherServlet _and_ *.jsp. Stripes does not require that the Stripes " +
"wrapper is the only request wrapper, or the outermost; only that it is present.",((HttpServletRequest)request).getRequestURL().toString()));
}
}
StripesRequestWrapper.java 文件源码
java
阅读 94
收藏 0
点赞 0
评论 0
项目:beyondj
作者:
评论列表
文章目录