1 24 package org.riotfamily.common.web.util; 25 26 import javax.servlet.http.HttpServletRequest ; 27 28 import org.springframework.web.util.UrlPathHelper; 29 30 33 public class ServletMappingHelper extends UrlPathHelper { 34 35 boolean useOriginalRequest = false; 36 37 public ServletMappingHelper() { 38 } 39 40 public ServletMappingHelper(boolean useOriginalRequest) { 41 this.useOriginalRequest = useOriginalRequest; 42 } 43 44 public void setUseOriginalRequest(boolean useOriginalRequest) { 45 this.useOriginalRequest = useOriginalRequest; 46 } 47 48 public String getLookupPathForRequest(HttpServletRequest request) { 49 if (useOriginalRequest) { 50 return ServletUtils.getOriginatingPathWithoutServletMapping(request); 51 } 52 return super.getLookupPathForRequest(request); 53 } 54 55 public String getServletPath(HttpServletRequest request) { 56 if (useOriginalRequest) { 57 return ServletUtils.getOriginatingServletPath(request); 58 } 59 return super.getServletPath(request); 60 } 61 62 public String getContextPath(HttpServletRequest request) { 63 if (useOriginalRequest) { 64 return getOriginatingContextPath(request); 65 } 66 return super.getContextPath(request); 67 } 68 69 public String getRequestUri(HttpServletRequest request) { 70 if (useOriginalRequest) { 71 return getOriginatingRequestUri(request); 72 } 73 return super.getRequestUri(request); 74 } 75 76 public String getQueryString(HttpServletRequest request) { 77 if (useOriginalRequest) { 78 return getOriginatingQueryString(request); 79 } 80 return request.getQueryString(); 81 } 82 83 public String getServletPrefix(HttpServletRequest request) { 84 return ServletUtils.getServletPrefix(request); 85 } 86 87 public String getServletSuffix(HttpServletRequest request) { 88 return ServletUtils.getServletSuffix(request); 89 } 90 91 public String getRootPath(HttpServletRequest request) { 92 return ServletUtils.getRootPath(request); 93 } 94 95 } 96 | Popular Tags |